必赢亚洲线mg:iOS梯度动画

作者:计算机知识

必赢亚洲线mg 1必赢亚洲线mg:iOS梯度动画。PJAnimatedMaskLabel.gif

- didMoveToWindow { [self.layer addSublayer:_gradientLayer]; CABasicAnimation *gradientAnimation = [CABasicAnimation animationWithKeyPath:@"locations"]; gradientAnimation.fromValue = @[@0.0, @0.0, @0.25]; gradientAnimation.toValue = @[@0.75, @1.0, @1.0]; gradientAnimation.duration = 3.0; gradientAnimation.repeatCount = CGFLOAT_MAX; [_gradientLayer addAnimation:gradientAnimation forKey:nil];}- setupUI { _gradientLayer = [CAGradientLayer layer]; _gradientLayer.colors = @[[UIColor blackColor].CGColor, [UIColor whiteColor].CGColor, [UIColor blackColor].CGColor]; _gradientLayer.locations = @[@0.25, @0.5, @0.75]; _gradientLayer.startPoint = CGPointMake; _gradientLayer.endPoint = CGPointMake;}

必赢亚洲线mg 2MaskLabel.gif

- layoutSubviews { [super layoutSubviews]; _gradientLayer.frame = CGRectMake(-self.bounds.size.width, self.bounds.origin.y, 3 * self.bounds.size.width, self.bounds.size.height);}

- setText:(NSString *)text withFontSize:size { [self setNeedsDisplay]; NSMutableDictionary *textAttributes = [NSMutableDictionary dictionary]; NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init]; style.alignment = NSTextAlignmentCenter; UIFont *font = [UIFont fontWithName:@"HelveticaNeue-Thin" size:size]; textAttributes[NSParagraphStyleAttributeName] = style; textAttributes[NSFontAttributeName] = font; UIGraphicsBeginImageContextWithOptions(self.frame.size, false, 0); [text drawInRect:self.bounds withAttributes:textAttributes]; UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); CALayer *maskLayer = [CALayer layer]; maskLayer.backgroundColor = [UIColor clearColor].CGColor; maskLayer.frame = CGRectOffset(self.bounds, self.bounds.size.width, 0); maskLayer.contents = (image.CGImage); _gradientLayer.mask = maskLayer;}

iOS Animations by Tutorials

本文由bwin必赢发布,转载请注明来源

关键词: 动画 必赢亚洲988.net iOS 梯度