Custom slideshow widget in Objective-c ui, objective-cui

Source: Internet
Author: User

Custom slideshow widget in Objective-c ui, objective-cui

The following is a custom carousel image class ImageLoop inherited from UIView. The class ImageLoop contains a UIScrollView and UIPageControl, which defines three attributes:

PageControll, position, currentPage can customize the pageControl style, you can also use position to control the playback direction, or set to start playing from an image whose subscript is currentPage.

The following is the ImageLoop interface file:

#import <UIKit/UIKit.h>typedef enum{Left,Right} Position;@interface ImageLoop : UIView@property (nonatomic,retain)UIPageControl *pageControll;@property (nonatomic,assign)Position position;@property (nonatomic,assign)NSInteger currentPage;- (instancetype)initWithFrame:(CGRect)frame imageArray:(NSMutableArray *)array position:(Position)position;@end

 

Initialize all controls in the initialization method, except pageControl, as well as scrollView, three uiimageviews, one timer

This demo carousel uses three uiimageviews to represent the displayed image, the left side of the displayed image, and the right side of the displayed image, by constantly setting the UIImage of three imageviews to achieve the carousel effect, when scrollView slides to the right, set the picture between the center and the left to the next image (pay attention to the boundary issue ), then let the scrollView slide to the middle, and then set the picture on the right to the next of the current image (also pay attention to the boundary issue), so that repeated playback can be achieved.

Because the control contains a timer, when the gesture slides, you need to stop the timer. After the image is switched successfully, a new timer is created to re-time the timer. Similarly, when the current image currentPage is set, you must stop the timer before restarting it. When you set the direction, the timer also stops and plays the video again based on the direction and timer.

 

The download link of the demo is as follows:

ImageLoop

 

 

Reprinted Please note: Author SmithJackyson

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.