- (void)viewDidLoad
{
[super viewDidLoad];
[self.view setBackgroundColor:[UIColor grayColor]];
// Do any additional setup after loading the view, typically from a nib.
MarqueeLabel *label = [[MarqueeLabel alloc]initWithFrame:CGRectMake(, , , )];
label.backgroundColor = [UIColor clearColor]; float fadeLength = 15.0f;
CAGradientLayer* gradientMask = [CAGradientLayer layer];
gradientMask.bounds = label.layer.bounds;
gradientMask.position = CGPointMake([label bounds].size.width / , [label bounds].size.height / );
NSObject *transparent = (NSObject*) [[UIColor clearColor] CGColor];
NSObject *opaque = (NSObject*) [[UIColor blackColor] CGColor];
gradientMask.startPoint = CGPointMake(0.0, CGRectGetMidY(label.frame));
gradientMask.endPoint = CGPointMake(1.0, CGRectGetMidY(label.frame));
float fadePoint = fadeLength/label.frame.size.width;
[gradientMask setColors: [NSArray arrayWithObjects: transparent, opaque, opaque, transparent, nil]];
[gradientMask setLocations: [NSArray arrayWithObjects:
[NSNumber numberWithFloat: 0.0],
[NSNumber numberWithFloat: fadePoint],
[NSNumber numberWithFloat: - fadePoint],
[NSNumber numberWithFloat: 1.0],
nil]];
label.layer.mask = gradientMask; label.text = @"者是一个测试程序测试长度适用的滚动的是就是";
[self.view addSubview:label];
}
05-11 13:19
查看更多