IOS Snowflake Animation and Marquee

Source: Internet
Author: User

This is the next one, on the animation effect of the collection, this article introduces the marquee animation and falling snowflakes animation, see, say how recently not in the state, good sad (embarrassed ~).
Previous-IOS faux yy Live Heart Animation & Fireworks Animation

Marquee Effect Demo

The use code is posted here, please download demo view for details.
Download ready to use-fast food--star encouragement


After downloading, in the VC so use, of course, the demo also reflects

- (void) Viewdidload {[SuperViewdidload];additional setup after loading the view. Self. View. BackgroundColor= [UicolorBlackcolor]; Xtscrolllabelview *drawmarqueeview = [[Xtscrolllabelview alloc] Initwithframe:cgrectmake (0,0,.F -)];d Rawmarqueeview. Delegate= Self;d Rawmarqueeview. Marqueedirection= Fromlefttype;drawmarqueeview. Center= Self. View. Center; [ Self. ViewAddsubview:drawmarqueeview]; [Drawmarqueeview addcontentview:[ Selfcreatelabelwithtext:@"Summer is a good season, and summer is the recommended author of Jane's book, like to share!"textcolor:[ SelfRandomcolor]]; [Drawmarqueeview startanimation];} - (UILabel*) Createlabelwithtext: (NSString*) Text TextColor: (Uicolor*) TextColor {NSString*string = [NSStringstringwithformat:@" %@ ", text];CGFloatwidth = [string Widthwithstringattribute:@{nsfontattributename: [UifontSystemfontofsize:.F]}];UILabel*label = [[UILabelAlloc] Initwithframe:cgrectmake (0,0, Width, -)];label. Font= [UifontSystemfontofsize:.F];label. Text= String;label. TextColor= TextColor;returnlabel;} - (Uicolor*) Randomcolor {return[Uicolorcolorwithred:[ SelfRandomvalue] green:[ SelfRandomvalue] blue:[ SelfRandomvalue] Alpha:1];} - (CGFloat) Randomvalue {returnArc4random ()% the/255.F;} - (void) Drawmarqueeview: (Xtscrolllabelview *) Drawmarqueeview animationdidstopfinished: (BOOL) Finished{[drawmarqueeview StopAnimation];d ispatch_after (Dispatch_time (Dispatch_time_now, (int64_t) (1.0* nsec_per_sec)), Dispatch_get_main_queue (), ^{[drawmarqueeview addcontentview:[ Selfcreatelabelwithtext:[ Selfrandomstring]textcolor:[ SelfRandomcolor]]; [Drawmarqueeview startanimation];}); - (NSString*) RandomString {Nsarray*array = @[@"Good for a person",@"hardworking",@"Young",@"Hard",@"joking.",@"I made it up, don't run in front."];returnArray[arc4random ()% array. Count];}
! Presentation (Http://upload-images.jianshu.io/upload_images/1506501-60f6dae4324b1ba1.gif?imageMogr2/auto-orient/strip) Snowflake Animation Code Demo

– this is written in Viewdidload and the comments are very detailed

//Create a particle layerCaemitterlayer *snowemitter = [Caemitterlayer layer];//Particle launch positionSnowemitter. Emitterposition= Cgpointmake ( -,0);//emission source sizeSnowemitter. Emittersize= Self. View. Bounds. Size;//TX modeSnowemitter. Emittermode= Kcaemitterlayersurface;//The shape of the transmitting sourceSnowemitter. Emittershape= Kcaemitterlayerline;//Create a snowflake-type particleCaemittercell *snowflake = [Caemittercell Emittercell];//The name of the particleSnowflake. Name= @"Snow";//Velocity multiplier factor for particle parametersSnowflake. birthrate=20.0; snowflake. Lifetime=120.0;//particle speedSnowflake. Velocity=10.0;//particle speed rangeSnowflake. Velocityrange=Ten;//particle acceleration component in y directionSnowflake. Yacceleration=2;//Ambient emission angleSnowflake. Emissionrange=0.5* M_PI;//Sub-rotation angle rangeSnowflake. Spinrange=0.25* M_pi;snowflake. Contents= (ID)[[UIImageimagenamed:@"Snow"] Cgimage];//Set the color of a snowflake-shaped particleSnowflake. Color= [[UicolorWhitecolor] Cgcolor];snowflake. Redrange=1.5F;snowflake. Greenrange=2.2F;snowflake. Bluerange=2.2F;snowflake. Scalerange=0.6F;snowflake. scale=0.7F;snowemitter. Shadowopacity=1.0; snowemitter. Shadowradius=0.0; snowemitter. Shadowoffset= Cgsizemake (0.0,0.0);//color of particle edgesSnowemitter. Shadowcolor= [[UicolorWhitecolor] Cgcolor];//Add particlesSnowemitter. Emittercells= @[snowflake];//Add a particle layer to the layer[ Self. View. LayerAddsublayer:snowemitter];//Mask formationUIImage*image = [UIImageimagenamed:@"Alpha"];_layer = [Calayer layer];_layer. Frame= (CGRect) {Cgpointzero, Self. View. Bounds. Size};_layer. Contents= (__bridgeID) (Image. Cgimage); _layer. Position= Self. View. Center; snowemitter. Mask= _layer;

—————————————

Walking Heart article, worth a praise-wen/summer and then
Weibo-dot I'm a grown man in summer | | qqq:498143780

IOS Snowflake Animation and Marquee

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.