图片切圆,label文字底部加一条线,自定义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:0green:0blue:0alpha:0.3].CGColor;

2.UILabel底部显示一条线

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

   NSRange strRange = {0,[strlength]};

    [str addAttribute:NSUnderlineStyleAttributeNamevalue:[NSNumbernumberWithInteger:NSUnderlineStyleSingle]range:strRange];

    [self.lblCheckDetailsetAttributedText:str];


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

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

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

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

   NSNumber *stopOne = [NSNumbernumberWithFloat:0.0];

   NSNumber *stopTwo = [NSNumbernumberWithFloat:1.0];

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

    CAGradientLayer *headerLayer = [CAGradientLayerlayer];

    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.layerinsertSublayer:headerLayer atIndex:0];

你可能感兴趣的:(图片切正圆,UILabel文字底部画一条线,自定义view的半透明渐变效果)