IOS9 implementation of Task Manager effects

Source: Internet
Author: User

IOS9 implementation of Task Manager effects

In IOS9, you can open Task Manager by double-clicking the Home button, which is different from the previous version, this time using the 3D effect, see:

So how do you create such effects in our app? There is a icarousel third-party framework on GitHub for our use. Here is the process of Learning Task Manager effects based on this library.

First, the simple realization function:

1, first download Icarousel frame, download good after any place to save anywhere, as long as you can find on OK.

2. Create a new iOS project, then click Add a group in the project file, name it Icarousel, then right-add the file, find the Icarousel in the file downloaded in the iCarousel.h and ICAROUSEL.M These two files and import them.

3, in the new project, there are use #import to import iCarousel.h in VIEWCONTROLLER.M. Then add the following statement in the -(void) Viewdidload {} function:

1 //Create a new 1 Icarousel object and initialize it2Icarousel *icar = [[Icarousel alloc]initwithframe:cgrectmake ( -, -,214, -)];3 //set the type of Icarousel to the time machine type4Icar.type =Icarouseltypetimemachine;5 //set up data sources and proxies6Icar.Delegate=Self ;7Icar.datasource =Self ;8     9 //Add the created Icarousel object to the current viewTen[Self.view Addsubview:icar];

The above completes the creation and initialization of the Icarousel object, and adds it to the current view and other work. Next look at the Icarousel data source and proxy method, in Xcode, command and click on the code above the Icarousel, will jump to the iCarousel.h file, the code is as follows:

1 @protocol Icarouseldatasource, icarouseldelegate; 2 3 @interface Icarousel:uiview 4 5 ID<iCarouselDataSource> dataSource; 6 ID delegate;

You can see that the Icarousel agent is Icarouseldatasource and icarouseldelegate, the same security command then click Icarouseldatasource, jump to the following code:

1 @protocolIcarouseldatasource <NSObject>2 3-(Nsinteger) Numberofitemsincarousel: (Icarousel *) Carousel;4-(UIView *) Carousel: (Icarousel *) Carousel Viewforitematindex: (nsinteger) Index Reusingview: (Nullable UIView *) view;5 6 @optional7 8-(Nsinteger) Numberofplaceholdersincarousel: (Icarousel *) Carousel;9-(UIView *) Carousel: (Icarousel *) Carousel Placeholderviewatindex: (nsinteger) Index Reusingview: (Nullable UIView *) view;Ten  One @end

It can be seen that there are four methods in this protocol that need to be implemented, the first two are to be implemented, the latter two are optional implementations, and then we take a closer look at the discovery that the first method according to the literal meaning of the number of elements in the Icarousel, the second method is to return a uiview, Parameter has index what, this time if used before UITableView will think, Icarousel and uitableview a bit like, next we copy these two methods into our program, and implement it:

1-(Nsinteger) Numberofitemsincarousel: (Icarousel *) carousel{2 //returns the number of item3     return Ten;4 }5-(UIView *) Carousel: (Icarousel *) Carousel Viewforitematindex: (nsinteger) Index Reusingview: (Nullable UIView *) view{6 //Initialize view and add elements above7     if(view==Nil) {8view = [[UIView alloc]initwithframe:cgrectmake ( -, -,214,214)];9View.backgroundcolor =[Uicolor Redcolor];TenView.contentmode =Uiviewcontentmodecenter; OneUILabel *label =[[UILabel alloc] initWithFrame:view.bounds]; ALabel.text =@"This is Icarousel practice ."; -Label.textalignment =Nstextalignmentcenter; - [view Addsubview:label]; the     } -     returnview; -}

By completing the above code, we can try to run it and see if it works:

It doesn't look good, but the basic function of this step has been achieved, and later on how to make it more beautiful.

IOS9 Task Manager effects

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.