Reputation: 3804
So you can get the width and height of the UIScreen as follows...
public var screenWidth: CGFloat {
return UIScreen.main.bounds.width
}
public var screenHeight: CGFloat {
return UIScreen.main.bounds.height
}
But how can you get the width and height of a UIView?
Upvotes: 6
Views: 14086
Reputation: 1679
extension UIView {
public var viewWidth: CGFloat {
return self.frame.size.width
}
public var viewHeight: CGFloat {
return self.frame.size.height
}
}
Upvotes: 18