Objective-c UI Custom Carousel Chart control

Source: Internet
Author: User

Here we customize a Carousel diagram Class Imageloop inherits from UIView, and the class Imageloop contains a Uiscrollview and Uipagecontrol, which defines three properties:

Pagecontroll,position,currentpage can customize the Pagecontrol style, or you can use position to control the direction of playback, or set a picture from subscript currentpage to start playing

Here is the interface file for Imageloop:

#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

Initializes all controls in the initialization method, in addition to the Pagecontrol, there are ScrollView, three Uiimageview, a timer timers

This demo carousel idea is to use three Uiimageview to represent the displayed picture, and display the picture on the left as well as the right side of the picture displayed, by constantly setting three ImageView uiimage to achieve the effect of the carousel, when the ScrollView slide to the right, Set the middle and left picture as the next picture (note the boundary problem), then let ScrollView slide to the middle, then set the picture on the right to the next (same note on the boundary problem) of the current picture, so repeat to play the loop.

Because the control includes a timer timer, so when the gesture swipe, to stop the timer, the picture after the successful switch to re-create a timer re-timer, again, set the current picture currentpage, to stop the timer before restarting. When you set the orientation, the timer also stops and then plays back according to the direction and timer.

Here is the download link for demo:

Imageloop

Reprint Please specify: Author Smithjackyson

Objective-c UI Custom Carousel Chart control

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.