Created
March 27, 2018 19:04
-
-
Save dennislysenko/7aa675ed83f2c02f91bbe2bf29c574de to your computer and use it in GitHub Desktop.
Tiny set of helpers to make autoresizing-mask-based programmatic UI prototyping more palatable.
This file contains hidden or 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
import UIKit | |
public extension UIView { | |
public var width: CGFloat { | |
set { | |
bounds.size.width = newValue | |
} | |
get { | |
return bounds.size.width | |
} | |
} | |
public var height: CGFloat { | |
set { | |
bounds.size.height = newValue | |
} | |
get { | |
return bounds.size.height | |
} | |
} | |
public var x: CGFloat { | |
set { | |
frame.origin.x = newValue | |
} | |
get { | |
return frame.origin.x | |
} | |
} | |
public var y: CGFloat { | |
set { | |
frame.origin.y = newValue | |
} | |
get { | |
return frame.origin.y | |
} | |
} | |
public var maxX: CGFloat { | |
set { | |
frame.origin.x = newValue - width | |
} | |
get { | |
return frame.origin.x + width | |
} | |
} | |
public var maxY: CGFloat { | |
set { | |
frame.origin.y = newValue - height | |
} | |
get { | |
return frame.origin.y + height | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment