Shimmer effect of fake Facebook

Source: Internet
Author: User

Shimmer effect of fake Facebook

Description

The main use of the cagradientlayer characteristics to achieve special effects, because time is limited, and has not been encapsulated, to be improved later.

Effect

Source code (source code is not encapsulated, details are not processed, hope forgive)

////FadeString.h//Fadewords////Created by youxianming on 15/5/7.//Copyright (c) 2015 youxianming. All rights reserved.//#import<UIKit/UIKit.h>@interfaceFadestring:uiview/** * Enter text*/@property (nonatomic, strong) NSString*text;/** * Fade to Right fades*/- (void) Faderight;@end
////FADESTRING.M//Fadewords////Created by youxianming on 15/5/7.//Copyright (c) 2015 youxianming. All rights reserved.//#import "FadeString.h"@interfacefadestring () @property (nonatomic, strong) UILabel*label; @property (Nonatomic, strong) UILabel*BackLabel, @property (nonatomic, strong) UIView*mask;//Mask as Mask@end@implementationfadestring-(Instancetype) initWithFrame: (CGRect) frame { self=[Super Initwithframe:frame]; if(self) {//Create a label[self createLabel:self.bounds]; //Create a mask[self createMask:self.bounds]; }    returnSelf ;}- (void) Createlabel: (CGRect) frame {Self.label=[[UILabel alloc] initwithframe:frame]; Self.label.font= [Uifont fontwithname:@"Avenirnext-ultralight"Size $. f]; Self.label.textAlignment=Nstextalignmentcenter; Self.label.textColor= [[Uicolor Cyancolor] Colorwithalphacomponent:0.5f]; [Self AddSubview:self.label];}- (void) Createmask: (CGRect) Frame {//Create a gradient layerCagradientlayer *gradientlayer =[Cagradientlayer layer]; Gradientlayer.frame=frame; Gradientlayer.colors= @[(__bridgeID) [Uicolor Clearcolor]. Cgcolor, (__bridgeID) [Uicolor Blackcolor]. Cgcolor, (__bridgeID) [Uicolor Blackcolor]. Cgcolor, (__bridgeID) [Uicolor Clearcolor].    Cgcolor]; Gradientlayer.locations= @[@(0.01), @(0.2), @(0.4), @(0.59)]; Gradientlayer.startpoint= Cgpointmake (0,0); Gradientlayer.endpoint= Cgpointmake (1,0); //Create and take over maskSelf.mask =[[UIView alloc] initwithframe:frame]; //Mask Get gradient layer[Self.mask.layer Addsublayer:gradientlayer]; CGRect Newframe=Self.mask.frame; Newframe.origin.x-= $; Self.mask.frame=Newframe; Self.maskview=Self.mask;}- (void) faderight {[UIView animatewithduration:5. F animations:^{CGRect frame=Self.mask.frame; Frame.origin.x+ = (Frame.size.width + -); Self.mask.frame=frame;    }]; }/** * Override Setter,getter Method*/@synthesizeText =_text;- (void) SetText: (NSString *) Text {_text=text; Self.label.text=text;}-(NSString *) Text {return_text;}@end
////VIEWCONTROLLER.M//Fadewords////Created by youxianming on 15/5/7.//Copyright (c) 2015 youxianming. All rights reserved.//#import "ViewController.h"#import "FadeString.h"@interfaceViewcontroller () @property (nonatomic, strong) UILabel*label; @property (Nonatomic, strong) fadestring*fadestring;@end@implementationViewcontroller- (void) viewdidload {[Super viewdidload]; Self.view.backgroundColor=[Uicolor Blackcolor]; Self.label= [[UILabel alloc] Initwithframe:cgrectmake (0,0, -, -)]; Self.label.font= [Uifont fontwithname:@"Avenirnext-ultralight"Size $. f]; Self.label.center=Self.view.center; Self.label.textAlignment=Nstextalignmentcenter; Self.label.textColor=[Uicolor Graycolor]; Self.label.text=@"youxianming";            [Self.view AddSubview:self.label]; //Create fadestringself.fadestring = [[Fadestring alloc] Initwithframe:cgrectmake (0,0, -, -)]; Self.fadeString.text=@"youxianming"; Self.fadeString.center=Self.view.center;            [Self.view addSubview:self.fadeString]; [Self performselector: @selector (Run) withobject:nil Afterdelay:4. f];}- (void) Run {//Performing animation effects[self.fadestring faderight];}@end

Key settings

Shimmer effect of fake Facebook

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.