ViewPlus

1.1.0

Make working with NSView more pleasant
ChimeHQ/ViewPlus

What's New

v1.1.0

2021-02-18T17:20:31Z

Include the XiblessViewController class

Github CI Carthage compatible

ViewPlus

ViewPlus is a small library that provides some helpful extension and capabilities for working with NSView.

Integration

Swift Package Manager

dependencies: [
    .package(url: "https://github.com/ChimeHQ/ViewPlus.git")
]

Carthage

github "ChimeHQ/ViewPlus"

Extensions

TrackingArea

func removeTrackingArea(with rect: NSRect)
func removeTrackingAreas(_ areas: [NSTrackingArea])
func removeAllTrackingAreas()

Auto Layout

var useAutoLayout: Bool
var subviewsUseAutoLayout: Bool

Animation

func animateLayout(changes: (NSAnimationContext) -> Void)

NSLayoutConstraint

func withPriority(_ p: NSLayoutConstraint.Priority) -> NSLayoutConstraint

NSLayoutConstraint.Priority

func offset(by: Float) -> NSLayoutConstraint.Priority

Classes

UnrestrictedLayerView

By default, the layer property of an NSView has a number of restrictions. There are many properties that are owned and controlled by the AppKit, and are impossible to modify in a safe and predictable way. This class provides a single property unrestrictedLayer, which has no restrictions whatsoever.

This layer will just match the frame of the hosting view. This is is a great way to integrate a layer into the Auto Layout system. It's also nice for applying transforms.

XiblessViewController

This is a very simple NSViewController subclass that eliminates some boilerplate for view controllers that always create their views programatically. This class is based on work on a blog post about view controllers without XIBs, and includes a lot of great discussion about the pros and cons of such an approach.

Suggestions or Feedback

We'd love to hear from you! Get in touch via twitter, an issue, or a pull request.

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Description

  • Swift Tools 5.0.0
View More Packages from this Author

Dependencies

  • None
Last updated: Mon Nov 15 2021 02:44:08 GMT-0500 (GMT-05:00)