This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// avoid ambiguous position by using wrapper | |
let wrapper = UIView() | |
let view = HeaderView() | |
view.translatesAutoresizingMaskIntoConstraints = false | |
wrapper.addSubview(view) | |
NSLayoutConstraint.activate([ | |
view.leftAnchor.constraint(equalTo: wrapper.leftAnchor), | |
view.rightAnchor.constraint(equalTo: wrapper.rightAnchor), | |
view.topAnchor.constraint(equalTo: wrapper.topAnchor), | |
view.bottomAnchor.constraint(equalTo: wrapper.bottomAnchor), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSLayoutConstraint.activate([ | |
play.rightAnchor.constraint( | |
equalTo: guide_mark.leftAnchor, | |
constant: -8 | |
) | |
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// add constraints through Autolayout Visual Format Language | |
view.addConstraints( | |
NSLayoutConstraint.constraints( | |
withVisualFormat: "H:|-50-[button]", | |
options: .alignAllTop, | |
metrics: nil, | |
views: objects | |
) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// UIViewController | |
let constraints = [ | |
view.centerXAnchor.constraint(equalTo: superview.centerXAnchor), | |
view.centerYAnchor.constraint(equalTo: superview.centerYAnchor), | |
view.widthAnchor.constraint(equalTo: superview.widthAnchor) | |
view.heightAnchor.constraint(equalTo: superview.heightAnchor), | |
] | |
NSLayoutConstraint.activate(constraints) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// UIView.h | |
@class NSLayoutXAxisAnchor,NSLayoutYAxisAnchor,NSLayoutDimension; | |
@interface UIView (UIViewLayoutConstraintCreation) | |
/* Constraint creation conveniences. See NSLayoutAnchor.h for details. | |
*/ | |
@property(nonatomic,readonly,strong) NSLayoutXAxisAnchor *leadingAnchor API_AVAILABLE(ios(9.0)); | |
@property(nonatomic,readonly,strong) NSLayoutXAxisAnchor *trailingAnchor API_AVAILABLE(ios(9.0)); | |
// more anchors... | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" File: nudge.py | |
An lldb Python script to add a nudge command. | |
Add to ~/.lldbinit: | |
command script import ~/path/to/nudge.py | |
Usage: | |
(lldb) nudge x-offset y-offset [view] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person { | |
var age: Int | |
init(age: Int) { | |
self.age = age | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person: NSObject { | |
@objc dynamic var age: Int | |
init(age: Int) { | |
self.age = age | |
super.init() | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface NSObject(NSKeyValueObserverRegistration) | |
/* Register or deregister as an observer of the value at a key path relative to the receiver. | |
The options determine what is included in observer notifications and when they're sent, as described above, | |
and the context is passed in observer notifications as described above. You should use | |
-removeObserver:forKeyPath:context: instead of -removeObserver:forKeyPath: whenever possible because it allows | |
you to more precisely specify your intent. When the same observer is registered for the same key path multiple times, | |
but with different context pointers each time, -removeObserver:forKeyPath: has to guess at the context pointer when | |
deciding what exactly to remove, and it can guess wrong. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (BOOL)shouldAutorotate { | |
return NO; | |
} | |
- (UIInterfaceOrientationMask)supportedInterfaceOrientations { | |
return (UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight); | |
} |
NewerOlder