我有一个带有UITextView的UIButton,因为它是子视图。 UITextView有1层,边框是彩色的,宽度为1.当我归档UIButton然后取消归档它时,边框颜色和边框宽度变为零。如果我设置图层背景颜色,它将在归档然后取消归档时保持不变,这使得此错误非常混乱。
UIButton textButton = ...
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:textButton];
UIButton *textButton2 = [NSKeyedUnarchiver unarchiveObjectWithData:data];
lldb调试输出显示边框颜色消失
(lldb) po [[[textButton subviews] firstObject] layer] <CALayer:0x13445780; position = CGPoint (150 50); bounds = CGRect (0 0; 300 100); delegate = <UITextView: 0xdb20000; frame = (0 0; 300 100); text = ''; clipsToBounds = YES; autoresize = RM+BM; userInteractionEnabled = NO; gestureRecognizers = <NSArray: 0x13446430>; layer = <CALayer: 0x13445780>; contentOffset: {0, 0}>; sublayers = (<_UITextTiledLayer: 0x13448e80>, <CALayer: 0x13445d90>); masksToBounds = YES; allowsGroupOpacity = YES; borderColor = <CGColor 0xc09b6d0> [<CGColorSpace 0xbf28210> (kCGColorSpaceDeviceRGB)] ( 0.378437 0.5 0.13035 1 ); backgroundColor = <CGColor 0xbed1e10> [<CGColorSpace 0xbe65e70> (kCGColorSpaceDeviceGray)] ( 0 0 ); borderWidth = 1>
(lldb) po [[[textButton2 subviews] firstObject] layer] <CALayer:0x13443fe0; position = CGPoint (150 50); bounds = CGRect (0 0; 300 100); delegate = <UITextView: 0xdb2aa00; frame = (0 0; 300 100); text = ''; clipsToBounds = YES; autoresize = RM+BM; userInteractionEnabled = NO; gestureRecognizers = <NSArray: 0x13432ed0>; layer = <CALayer: 0x13443fe0>; contentOffset: {0, 0}>; sublayers = (<_UITextTiledLayer: 0x134447f0>, <CALayer: 0x13434740>); masksToBounds = YES; allowsGroupOpacity = YES; backgroundColor = <CGColor 0xbed1e10> [<CGColorSpace 0xbe65e70> (kCGColorSpaceDeviceGray)] ( 0 0 )>
边框颜色有什么特别之处吗?或者这真的是一个错误吗?