Textkit Simple Example
Effect
Source
Https://github.com/YouXianMing/Animations
////TEXTKITLOADIMAGECONTROLLER.M//Animations////Created by youxianming on 16/4/10.//copyright©2016 year youxianming. All rights reserved.//#import "TextKitLoadImageController.h"#import "Attributedstringinitconfig+constructor.h"#import "JSAnimatedImagesView.h"#import "uiview+setrect.h"#import "GCD.h"@interfaceTextkitloadimagecontroller () <JSAnimatedImagesViewDataSource>@property (nonatomic, strong) Jsanimatedimagesview*Jsview, @property (nonatomic, strong) Nsarray*Jsviewdatasource;@end@implementationTextkitloadimagecontroller- (void) Setup {[Super Setup]; NSString*str =@"This is happening in Alaska Mckenley National Park, the park is the size of Japan's Shikoku, but only a visitor center for tourists, located in the middle of the wilderness, the only road in the park, every day there are many tourists take advantage of this recreation place. \ n This neighborhood is the Arctic squirrel habitat, so whenever there are tourists get off, the ground squirrel will run to beg for food, completely not afraid of people, park administrators have repeatedly appealed to tourists do not feed the squirrel, but no matter from which country people, see cute machine of the ground squirrel, or will be tempted to throw things to them to eat. A year ago, a strange sign was erected in the park. Why do you say it's strange? Because this sign only 10 centimeters high, do not bend down the words can not see, the sign begins to write: "Ground squirrels!" "Originally, this is to the ground squirrel to see the warning." \ n "... You continue to eat human food, will be more and more fat, and finally run, you have to be golden eagle or bear to eat ... "The thought of a curious tourist to make a wry face, I can not help but smile. Also think that in the Japanese zoo, see tourists continue to the bear's cage to lose food, hanging next to the "do not feed" signs, looks so weak. It's clear that some people see animals as they naturally want to feed them, but some people think it's wrong. It's hard to stick to the truth, but it's better to think more about space and to persuade people with a little humor. "; Nstextstorage*storage =[[Nstextstorage alloc] initwithstring:str attributes:[attributedstringinitconfig Heitisc]]; //ManagerNslayoutmanager *layoutmanager = [NslayoutmanagerNew]; [Storage Addlayoutmanager:layoutmanager]; //displayed container (corresponds to Uitextview)Nstextcontainer *textcontainer = [NstextcontainerNew]; Cgsize size= Cgsizemake (Width- -, maxfloat); Textcontainer.size=size; [LayoutManager Addtextcontainer:textcontainer]; Uitextview*textview = [[Uitextview alloc] Initwithframe:cgrectmake (Ten,Ten, Width- -, Self.contentView.height- -) Textcontainer:textcontainer]; Textview.scrollenabled=YES; TextView.layer.borderWidth=0.5f; TextView.layer.borderColor= [[Uicolor Graycolor] Colorwithalphacomponent:0.15f]. Cgcolor; Textview.editable=NO; Textview.selectable=NO; TextView.layer.masksToBounds=NO; Textview.showsverticalscrollindicator=NO; TextView.layer.masksToBounds=YES; [Self.contentview Addsubview:textview]; CGRect Imagesframe= CGRectMake ( -, -, Textview.width- -*2, the); Textcontainer.exclusionpaths=@[[self Bezierpathwithframe:imagesframe]]; [Gcdqueue executeinmainqueue:^{self. Jsviewdatasource= @[[uiimage imagenamed:@"pic_1"], [UIImage imagenamed:@"pic_2"], [UIImage imagenamed:@"Pic_3"], [UIImage imagenamed:@"Pic_4"]]; Self. Jsview=[[Jsanimatedimagesview alloc] initwithframe:imagesframe]; Self. Jsview.alpha=0. F; Self. Jsview.transitionduration=2. F; Self. Jsview.datasource=Self ; Self. JSView.layer.masksToBounds=YES; [TextView addsubview:self. Jsview]; [UIView animatewithduration:2. F animations:^{self. Jsview.alpha=1. F; }]; } afterdelaysecs:0.5f];}-(Uibezierpath *) Bezierpathwithframe: (CGRect) Frame {return[Uibezierpath bezierpathwithrect:frame];}-(Nsuinteger) Animatedimagesnumberofimages: (Jsanimatedimagesview *) Animatedimagesview {returnSelf . Jsviewdatasource.count;}-(UIImage *) Animatedimagesview: (Jsanimatedimagesview *) Animatedimagesview Imageatindex: (nsuinteger) Index {returnSelf . Jsviewdatasource[index];}@end
Textkit Simple Example