Skip to content

Instantly share code, notes, and snippets.

@mbbischoff
Created April 21, 2016 21:54
Show Gist options
  • Save mbbischoff/4b371f0d2a63fcd3dfc71d80b1290139 to your computer and use it in GitHub Desktop.
Save mbbischoff/4b371f0d2a63fcd3dfc71d80b1290139 to your computer and use it in GitHub Desktop.
class ImmovableView: UIView {
/// `true` if setting the receiver’s frame should affect the view’s position and size. `false` if the view should be locked in place. Defaults to `true`.
var canMove = true
override var frame: CGRect {
get {
return super.frame
}
set {
guard canMove else { return }
super.frame = newValue
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment