Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone UILabel alpha也会导致文本褪色_Iphone_Objective C_Ios_Ipad - Fatal编程技术网

Iphone UILabel alpha也会导致文本褪色

Iphone UILabel alpha也会导致文本褪色,iphone,objective-c,ios,ipad,Iphone,Objective C,Ios,Ipad,有没有一种方法可以设置UILabel的alpha,但它不会淡出UILabel的文本?仅指背景?您可能需要创建背景视图(UIView就足够了),并将UILabel放在顶部(不是作为子视图,因为背景视图的alpha值影响其所有子视图)因为文本是标签的一部分,如果为标签设置alpha,则文字会相应淡入淡出。您需要的是使用适当的alpha设置backgroundColor: myLabel.backgroundColor = [UIColor colorWithRed:1 green:0 blue:0

有没有一种方法可以设置UILabel的alpha,但它不会淡出UILabel的文本?仅指背景?

您可能需要创建背景视图(
UIView
就足够了),并将
UILabel
放在顶部(不是作为子视图,因为背景视图的alpha值影响其所有子视图)

因为文本是标签的一部分,如果为标签设置alpha,则文字会相应淡入淡出。您需要的是使用适当的alpha设置
backgroundColor

myLabel.backgroundColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:0.5];