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