Skip to content

Instantly share code, notes, and snippets.

@mattbischoff
Created April 21, 2016 21:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattbischoff/4b371f0d2a63fcd3dfc71d80b1290139 to your computer and use it in GitHub Desktop.
Save mattbischoff/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