I have an UIImageView
in the self.view
(the main View) and inside it there is a UIButton
. I want to know what's the frame of UIButton
in self.view
not in UIImageView
.
swift, override viewDidLoad(). Create a CGRect that will be the frame of a UIView. Next, create an instance of UIView and set its backgroundColor property to blue. Finally, add the UIView as a subview of the view controller's view to make it part of the view hierarchy.
Frame A view's frame ( CGRect ) is the position of its rectangle in the superview 's coordinate system. By default it starts at the top left. Bounds A view's bounds ( CGRect ) expresses a view rectangle in its own coordinate system.
Just one single method will let you to bring your view to the front and the magic words are : myView. bringToFront(); “.
The bounds rectangle, which describes the view's location and size in its own coordinate system.
I guess you are looking for this method
– convertRect:toView:
// Swift let frame = imageView.convert(button.frame, to: self.view) // Objective-C CGRect frame = [imageView convertRect:button.frame toView:self.view];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With