码迷,mamicode.com
首页 > 其他好文 > 详细

图片切圆,label文字底部加一条线,自定义view的透明度渐变效果

时间:2015-08-05 12:59:04      阅读:114      评论:0      收藏:0      [点我收藏+]

标签:图片切正圆   uilabel文字底部画一条线   自定义view的半透明渐变效果   

1.图片头像切成圆【不是半径的话 不是正圆】

    self.imgvHead.clipsToBounds = YES;

    self.imgvHead.layer.cornerRadius = self.imgvHead.bounds.size.height/2;

    self.imgvHead.layer.borderWidth = 0.5f;

    self.imgvHead.layer.borderColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.3].CGColor;

2.UILabel底部显示一条线

    NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:self.lblCheckDetail.text];

    NSRange strRange = {0,[str length]};

    [str addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:strRange];

    [self.lblCheckDetail setAttributedText:str];

3.自定义一个透明度渐变的效果

    UIColor *colorOne = [UIColor colorWithRed:(33/255.0green:(33/255.0blue:(33/255.0alpha:0.0];

    UIColor *colorTwo = [UIColor colorWithRed:(33/255.0green:(33/255.0blue:(33/255.0alpha:1.0];

    NSArray *colors = [NSArray arrayWithObjects:(id)colorOne.CGColor, colorTwo.CGColornil];

    NSNumber *stopOne = [NSNumber numberWithFloat:0.0];

    NSNumber *stopTwo = [NSNumber numberWithFloat:1.0];

    NSArray *locations = [NSArray arrayWithObjects:stopOne, stopTwo,  nil];

    CAGradientLayer *headerLayer = [CAGradientLayer layer];

    headerLayer.colors = colors;

    headerLayer.locations = locations;

    CGFloat width = self.viewGradualAlpha.bounds.size.width + SCREEN_WIDTH - self.cellimgvTop.bounds.size.width;

    CGFloat height= self.viewGradualAlpha.bounds.size.height;

    headerLayer.frame = CGRectMake(0, 0, width, height);

    [self.viewGradualAlpha.layer insertSublayer:headerLayer atIndex:0];

版权声明:本文为博主原创文章,未经博主允许不得转载。

图片切圆,label文字底部加一条线,自定义view的透明度渐变效果

标签:图片切正圆   uilabel文字底部画一条线   自定义view的半透明渐变效果   

原文地址:http://blog.csdn.net/luobo140716/article/details/47293643

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!