0x00
打印按钮的layer
:
po _button.layer.sublayers
<CALayerArray 0x28247b780>(
<_UILabelLayer:0x2808bd0e0; position = CGPoint (45 20.1667); bounds = CGRect (0 0; 40 19); delegate = <UIButtonLabel: 0x118b6d460; frame = (25 10.6667; 40 19); text = '已过期'; opaque = NO; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x2808bd0e0>>; sublayers = (<_UILabelContentLayer: 0x282bb6f20>); allowsGroupOpacity = YES; contentsMultiplyColor = (null); rasterizationScale = 3; contentsScale = 3>
<CAGradientLayer:0x282bb70e0; position = CGPoint (45 20); bounds = CGRect (0 0; 90 40); allowsGroupOpacity = YES; endPoint = CGPoint (1 0); startPoint = CGPoint (0 0); colors = (
"<CGColor 0x280f80ea0> [<CGColorSpace 0x280f337e0> (kCGColorSpaceICCBased; kCGColorSpaceModelRGB; sRGB IEC61966-2.1; extended range)] ( 1 0.313725 0.466667 1 )",
"<CGColor 0x280f80f00> [<CGColorSpace 0x280f337e0> (kCGColorSpaceICCBased; kCGColorSpaceModelRGB; sRGB IEC61966-2.1; extended range)] ( 1 0.34902 0.866667 1 )"
)>
)
发现是自定义的CAGradientLayer
覆盖了标题的_UILabelLayer
0x01
把自定义的layer
放在最下层即可
[_button.layer insertSublayer:_layer atIndex:0];
这里有个渐变色的进度条
https://github.com/xjh093/JHGradualProgressView