Ios 360-degree rotation effect demo ios 360-degree rotation effect demo

Source: Internet
Author: User

Demo function: Use UIimageView to achieve 360-degree rotation.

Demo Description: iPhone6.1 is successfully tested. The main code is FVImageSequence. m. In the touchesMoved event, the rotation effect is generated by replacing the image of UIimageView.

Demo screenshot:

 

 


Demo main code:

[Html]
-(Void) touchesMoved :( NSSet *) touches withEvent :( UIEvent *) event {
[Super touchesMoved: touches withEvent: event];

UITouch * touch = [[event allTouches] anyObject];
CGPoint touchLocation = [touch locationInView: self];

Int location = touchLocation. x;
// Determine the direction of rotation based on the moving offset.

If (location <previous)
Current + = increment;
Else
Current-= increment;

Previous = location;

// Specifies the image critical point. All images in the image folder in the demo are taken from different angles. You can display these images in sequence to achieve a 360 rotation effect.
If (current> numberOfImages)
Current = 0;
If (current <0)
Current = numberOfImages;

NSString * path = [NSString stringWithFormat: @ "% @ % d", prefix, current];
NSLog (@ "% @", path );

Path = [[NSBundle mainBundle] pathForResource: path ofType: extension];


UIImage * img = [[UIImage alloc] initWithContentsOfFile: path];

// Set the image of UIimageView as a new image to achieve 360-degree rotation
[Self setImage: img];

[Img release];

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.