Skip to content

Instantly share code, notes, and snippets.

@atheken
Last active August 29, 2015 14:14
Show Gist options
  • Save atheken/d7d80b97e41195e56069 to your computer and use it in GitHub Desktop.
Save atheken/d7d80b97e41195e56069 to your computer and use it in GitHub Desktop.
Make "TranslatesAutoresizingMaskIntoConstraints" a drop-down in Interface Builder.
@IBDesignable
class TranslateResizeMaskToConstraints: UIView {
@IBInspectable var Enabled:Bool = false
private var _interfaceBuilderContext = false
override func awakeFromNib() {
super.awakeFromNib()
setTranslatesAutoresizingMaskIntoConstraints(Enabled || _interfaceBuilderContext)
}
override func prepareForInterfaceBuilder() {
_interfaceBuilderContext = true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment