IOS development-CGAffineTransformMakeRotation changed the central solution, cgaffinetransform
Poor Dad. It took two hours to solve the problem. Annoying ..
When I wrote a clock demo today, CGAffineTransformMakeRotation was used for clockwise rotation. the rotation of an image is centered on the image itself, that is, its center is fixed during the rotation process. The effect is the same as that of our hour hands.
For example, the Code for rotating the hour hand, minute hand, and second hand below me:
NSDate *today = [NSDate date]; NSCalendar *calendar = [NSCalendar currentCalendar]; unsigned flags = NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit; NSDateComponents *todayComponents = [calendar components:flags fromDate:today]; int hour = [todayComponents hour]; int min = [todayComponents minute]; int sec = [todayComponents second]; float fineHour = (hour % 12) + min /60.0; hourHand.transform = CGAffineTransformMakeRotation(M_PI * 2 * fineHour / 12.0); minuteHand.transform = CGAffineTransformMakeRotation(M_PI * 2 * min / 60.0); secondHand.transform = CGAffineTransformMakeRotation(M_PI * 2 * sec / 60.0);
The code is okay.
However, when running, it is found that the center has changed during the rotation process. Obvious displacement...
After a long time, it turned out to be an automatic layout.
Solution:
1. Disable Automatic Layout.
2. You should set the constraints of the center, rather than the constraints of the edge location.
Solved. Sleeping ..
Control rotation in ios development
Slider. transform = CGAffineTransformMakeRotation (90 * M_PI/180 );
Where is the developer version of IOS 8 located on the Developer Center website? How to download?
Login .apple.com/and click member center above.
Click iOS in Technical Resources and Tools.
Then we can see the iOS 8 beta. However, you need to sign an agreement first.