The use of ios-picture Carousel-sdcyclescrollview

Source: Internet
Author: User

Description: Sdcyclescrollview is a very powerful carousel diagram for third parties. Smooth rotation, smooth hand-slip. Easy to use. Simple customization. You can change the Pagecontrol.

I. Demo address Https://pan.baidu.com/disk/home#list/path=%2F summary%2fdemo-picture carousel

Two. Effects.

Three. Code.

#import "ViewController.h"#import "Masonry.h"#import "SDCycleScrollView.h"#defineKwidth [UIScreen mainscreen].bounds.size.width@interfaceViewcontroller () <SDCycleScrollViewDelegate>@property (nonatomic, strong) Uiimageview*Bgimageview, @property (nonatomic, strong) Uiscrollview*Bgscrollview;//Local Pictures@property (nonatomic, strong) Sdcyclescrollview *Localcyclescrollview;//Network Pictures@property (nonatomic, strong) Sdcyclescrollview *Webcyclescrollview;//Custom Pagecontrol@property (nonatomic, strong) Sdcyclescrollview *Customcyclescrollview;//Marquee Effect@property (nonatomic, strong) Sdcyclescrollview *Textcyclescrollview;@end/** Scroll Control interface 1. Autoscrolltimeinterval auto-scroll interval, default is 2s. 2. Infiniteloop is infinite loop. 3. AutoScroll whether to scroll the settings. 4. Scrolldirection picture scrolling direction. 5. Delegate set up the agent. 6. adjustwhencontrollerviewwillappera resolves viewwillappear when the Carousel card is in half of the problem, call this method 7 when the controller viewwillappear. *//** Custom Style interface 1. Bannerimageviewcontentmode the Contentmode of the carousel graph, the default is Uiviewcontentmodescaletofill 2. Placeholderimage occupies bitmap For Network 3. Showpagecontrol whether paging control 4 is displayed. Hidesforsinglepage if the Pagecontrol is hidden when there is only one picture, the default is yes. 5. Onlydisplaytext only displays text Carousel 6. Pagecontrolstyle style. The default is animation style 7. Pagecontrolaliment the location of the paging control 8. Pagecontrolbottomoffset the right spacing of the paging control from the carousel. 9. Pagecontroldotsize the size of the small round label of the paging control 10. Currentpagedotcolor Current paging control small round color 11. Currentpagedotimage picture of the current paging control small Circle 12. Pagedotimage other pagination controls small round label picture 13. Titlelabeltextcolor Carousel Text Label font Color 14. Titlelabeltextfont the font size of the Carousel text label 15. Titlelabelbackgroundcolor Carousel Text Label background color 16. Titlelabelheight Carousel Text Font height*//** Clear Cache 1. Clearimagescache [Sdcyclescrollview Clearimagescache];*/@implementationViewcontroller#pragmaMark-Life cycle-(void) Viewwillappear: (BOOL) animated{[Super viewwillappear:animated]; //If you find that your cyclescrollview will be in the middle of the viewwillappear, you can call this method to adjust the position of the picture.//[Your Cyclescrollview adjustwhencontrollerviewwillappera];}- (void) Viewwilldisappear: (BOOL) animated{[Super viewwilldisappear:animated];}#pragmaMark Viewdidload-(void) viewdidload{[Super Viewdidload];        [Self basicsetting];        [Self addbgmodule]; //locally stored pictures[self local_storage]; //Network Pictures[self webimage];        [Self Cuatompagecontrol]; [Self onlytext];}#pragmaMark-System Agent#pragmaMark Sdcyclescrollviewdelegate//Click the image proxy method- (void) Cyclescrollview: (Sdcyclescrollview *) Cyclescrollview Didselectitematindex: (nsinteger) index{NSLog (@"---Clicked on the image of page%ld", (Long) (index); //clean up the cache[Sdcyclescrollview Clearimagescache];}//Scroll to the first few pictures of the callback-(void) Cyclescrollview: (Sdcyclescrollview *) Cyclescrollview Didscrolltoindex: (nsinteger) index{NSLog (@">>>>>> Scroll to the first%ld map", (Long) (index);}#pragmaMark-click events#pragmaMark-Implementation Method#pragmaMark Basic Settings-(void) basicsetting{Self.title=@"";}- (void) addbgmodule{[Self.view AddSubview:self.bgImageView]; [Self.bgimageview mas_makeconstraints:^ (Masconstraintmaker *Make ) {Make.edges.mas_equalTo (Self.view). With.insets (Uiedgeinsetsmake (0,0,0,0));        }];    [Self.view AddSubview:self.bgScrollView]; [Self.bgscrollview mas_makeconstraints:^ (Masconstraintmaker *Make ) {Make.edges.mas_equalTo (Self.view). With.insets (Uiedgeinsetsmake (0,0,0,0)); }];}- (void) local_storage{[Self.bgscrollview AddSubview:self.localCycleScrollView]; [Self.localcyclescrollview mas_makeconstraints:^ (Masconstraintmaker *Make ) {Make.left.mas_equalTo (Self.bgscrollview). With.offset (0);        Make.width.mas_equalTo (Kwidth); Make.top.mas_equalTo (Self.bgscrollview). With.offset ( -); Make.height.mas_equalTo ( the); }];}- (void) webimage{[Self.bgscrollview AddSubview:self.webCycleScrollView]; [Self.webcyclescrollview mas_makeconstraints:^ (Masconstraintmaker *Make ) {Make.left.mas_equalTo (Self.bgscrollview). With.offset (0);        Make.width.mas_equalTo (Kwidth); Make.top.mas_equalTo (Self.localCycleScrollView.mas_bottom). With.offset ( -); Make.height.mas_equalTo ( the); }];}- (void) cuatompagecontrol{[Self.bgscrollview AddSubview:self.customCycleScrollView]; [Self.customcyclescrollview mas_makeconstraints:^ (Masconstraintmaker *Make ) {Make.left.mas_equalTo (Self.bgscrollview). With.offset (0);        Make.width.mas_equalTo (Kwidth); Make.top.mas_equalTo (Self.webCycleScrollView.mas_bottom). With.offset ( -); Make.height.mas_equalTo ( the); }];}- (void) onlytext{[Self.bgscrollview AddSubview:self.textCycleScrollView]; [Self.textcyclescrollview mas_makeconstraints:^ (Masconstraintmaker *Make ) {Make.left.mas_equalTo (Self.bgscrollview). With.offset (0);        Make.width.mas_equalTo (Kwidth); Make.top.mas_equalTo (Self.customCycleScrollView.mas_bottom). With.offset ( -); Make.height.mas_equalTo ( +); }];}#pragmaMark-setter & getter-(Uiimageview *) bgimageview{if(!_bgimageview) {Self.bgimageview=[[Uiimageview alloc] init]; Self.bgImageView.image= [UIImage imagenamed:@"005.jpg"]; }    return_bgimageview;}-(Uiscrollview *) bgscrollview{if(!_bgscrollview) {Self.bgscrollview=[[Uiscrollview alloc] init]; Self.bgScrollView.backgroundColor=[Uicolor Clearcolor]; Self.bgScrollView.contentSize= Cgsizemake (Kwidth, -); }    return_bgscrollview;}#pragmaMark Carousel-(Sdcyclescrollview *) localcyclescrollview{if(!_localcyclescrollview) {Nsarray* Localimagearray = @[@"h1.jpg",                                      @"h2.jpg",                                      @"h3.jpg",                                      @"h4.jpg",                                      @"H7" //Local picture Please fill in the full name                                      ]; Self.localcyclescrollview=[Sdcyclescrollview Cyclescrollviewwithframe:cgrectzero shouldinfiniteloop:yes Imagenamesgroup:localimagearray        ]; Self.localcyclescrollview.Delegate=Self ; Self.localCycleScrollView.scrollDirection=Uicollectionviewscrolldirectionhorizontal; Self.localCycleScrollView.autoScrollTimeInterval=1; }    return_localcyclescrollview;}-(Sdcyclescrollview *) webcyclescrollview{if(!_webcyclescrollview) {Self.webcyclescrollview= [Sdcyclescrollview Cyclescrollviewwithframe:cgrectzeroDelegate: Self placeholderimage:[uiimage imagenamed:@"placeholder"]]; //the location of the paging controlSelf.webCycleScrollView.pageControlAliment =Sdcyclescrollviewpagecontolalimentright; //titleSelf.webCycleScrollView.titlesGroup = @[@"1",@"2",@"3"]; //Network Image ArrayNsarray * imagesurlstrings = @[@"1",@"2",@"http://pic1.win4000.com/wallpaper/4/510f446941311.jpg"]; Self.webCycleScrollView.imageURLStringsGroup=imagesurlstrings; }    return_webcyclescrollview;}-(Sdcyclescrollview *) customcyclescrollview{if(!_customcyclescrollview) {Self.customcyclescrollview= [Sdcyclescrollview Cyclescrollviewwithframe:cgrectzeroDelegate: Self placeholderimage:[uiimage imagenamed:@"placeholder"]]; Self.customCycleScrollView.currentPageDotImage= [UIImage imagenamed:@"Pagecontrolcurrentdot"]; Self.customCycleScrollView.pageDotImage= [UIImage imagenamed:@"Pagecontroldot"]; //Network Image ArrayNsarray *imagesurlstrings = @[                                      @"https://ss2.baidu.com/-vo3dSag_xI4khGko9WTAnF6hhy/super/whfpf%3D425%2C260%2C50/sign= A4b3d7085dee3d6d2293d48b252b5910/0e2442a7d933c89524cd5cd4d51373f0830200ea.jpg",                                      @"https://ss0.baidu.com/-Po3dSag_xI4khGko9WTAnF6hhy/super/whfpf%3D425%2C260%2C50/sign= A41eb338dd33c895a62bcb3bb72e47c2/5fdf8db1cb134954a2192ccb524e9258d1094a1e.jpg",                                      @"http://c.hiphotos.baidu.com/image/w%3D400/sign=c2318ff84334970a4773112fa5c8d1c0/ B7fd5266d0160924c1fae5ccd60735fae7cd340d.jpg"                                      ]; Self.customCycleScrollView.imageURLStringsGroup=imagesurlstrings; }    return_customcyclescrollview;}-(Sdcyclescrollview *) textcyclescrollview{if(!_textcyclescrollview) {Self.textcyclescrollview= [Sdcyclescrollview Cyclescrollviewwithframe:cgrectzeroDelegate: Self placeholderimage:nil]; Self.textCycleScrollView.scrollDirection=uicollectionviewscrolldirectionvertical; Self.textCycleScrollView.onlyDisplayText=YES; Self.textCycleScrollView.titlesGroup= @[@"first one",@"a second",@"a third"]; }    return_textcyclescrollview;}@end

The use of ios-picture Carousel-sdcyclescrollview

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.