简体   繁体   中英

subview location after UIView Rotation

I have UIView which have subviews , I have rotated view with 90.

CGAffineTransform transform = CGAffineTransformMakeRotation(degreesToRadians(degrees));

Now I need to subview location in screen coordinate system and for that I am doing

CGPoint subViewPoint = [[subView superview]  convertPoint:subView.frame.origin toView:baseView];

This is working fine , if I am not rotating the View but its not working if i am rotating the view. Please help me on this.

How to get the subview location in screen after its super view 90 rotation.

I'm not sure, but there are two things to know.

1) You should avoid using frame property when you have to deal with transformations. Use center and bounds properties instead. Frames of views that have not identity transformations are invalid.

2) You can always use CGPointApplyAffineTransform function to calculate point coordinates by yourself : )

Hope this'll help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM