Reputation: 3276
How do I get the current height of any element using swift 2?
Any element would be: Buttons, UIImageViews, Labels, Navigation Bars, etc.
Upvotes: 3
Views: 4182
Reputation: 12562
let view = UIView(frame: CGRect(origin: zero, size: CGSize(width: 10, height: 20)))
print("height = \(view.frame.height)") // prints "height = 20"
All elements you listed inherit from UIView
, so they all have a frame
property, which has a height
property.
Upvotes: 3