Adding a CGGradient as sublayer to UILabel hides the text of label

前端 未结 5 1126
青春惊慌失措
青春惊慌失措 2020-12-03 17:17

I want to add the gradient as a background to label. I used the following code to acheive that. but the problem is that though the gradient color appears on the label, but t

5条回答
  •  醉话见心
    2020-12-03 17:25

    I think you can create a gradient color by adjusting the alpha value in the above code.

    gradient.colors = [NSArray arrayWithObjects:(id)[[UIColor whiteColor] CGColor],(id)[[UIColor colorWithRed:255/255.0 green:239/255.0 blue:215/255.0 alpha:0.1] CGColor],nil];
    

    I was able to get a gradient effect by doing so.

提交回复
热议问题