在模拟器中选中 `Color Blended Layers`后 UILabel 被标记为红色 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
iOS 开发实用技术导航
NSHipster 中文版
http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
http://www.cocos2d-iphone.org/
CocoaPods
http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
http://code.google.com/mobile/analytics/
WWDC
https://developer.apple.com/wwdc/
Design Guides and Resources
https://developer.apple.com/design/
Transcripts of WWDC sessions
http://asciiwwdc.com
Cocoa with Love
http://cocoawithlove.com/
Cocoa Dev Central
http://cocoadevcentral.com/
NSHipster
http://nshipster.com/
Style Guides
Google Objective-C Style Guide
NYTimes Objective-C Style Guide
Useful Tools and Services
Charles Web Debugging Proxy
Smore
xi_lin
V2EX    iDev

在模拟器中选中 `Color Blended Layers`后 UILabel 被标记为红色

  •  
  •   xi_lin 2016-01-20 17:22:47 +08:00 5792 次点击
    这是一个创建于 3634 天前的主题,其中的信息可能已经有所发展或是发生改变。
    这些被标记为红色的 UILabel 可以确定 backgroundColor 是 whiteColor 或者 redColor ,而且 opaque 没有被修改,是 YES

    还会有什么设置导致这个问题不?
    第 1 条附言    2016-01-21 00:13:02 +08:00

    在开启Color Blended Layers之后,notifyDateLabel是绿色的,其他几个 label 都是红色的。

    - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { self.senderNameLabel = [UILabel mt_labelWithFont:FONT(17) andColor:COLOR_NAV_TITLE]; self.senderNameLabel.backgroundColor = [UIColor whiteColor]; [self.contentView addSubview:self.senderNameLabel]; self.actiOnTextLabel= [UILabel mt_labelWithFont:FONT(15) andColor:COLOR_NAV_TITLE]; self.actionTextLabel.numberOfLines = 5; self.actionTextLabel.backgroundColor = [UIColor whiteColor]; [self.contentView addSubview:self.actionTextLabel]; self.notifyDateLabel = [UILabel mt_labelWithFont:FONT(12) andColor:COLOR_NAV_TITLE]; self.notifyDateLabel.backgroundColor = [UIColor whiteColor]; [self.contentView addSubview:self.notifyDateLabel]; [self setLayoutConstraints]; } return self; } 
    第 2 条附言    2016-01-21 00:13:26 +08:00
    - (void)setLayoutConstraints { CGFloat offsetX = 70; CGFloat offsetY = 15; CGFloat maxWidth = SCALE_WITH_RATIO(180); [self.senderNameLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.contentView).offset(offsetX); make.top.equalTo(self.contentView).offset(offsetY); make.width.mas_lessThanOrEqualTo(maxWidth); }]; offsetY = 12.5; maxWidth = SCALE_WITH_RATIO(180); [self.actionTextLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.senderNameLabel.mas_bottom).offset(offsetY); make.left.equalTo(self.senderNameLabel); make.width.mas_lessThanOrEqualTo(maxWidth); }]; offsetY = 10; CGFloat bottomOffsetY = -15; [self.notifyDateLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.actionTextLabel.mas_bottom).offset(offsetY); make.left.equalTo(self.senderNameLabel); make.bottom.equalTo(self.contentView).offset(bottomOffsetY); }]; } - (void)prepareForReuse { [super prepareForReuse]; self.senderNameLabel.text = nil; self.actionTextLabel.text = nil; self.notifyDateLabel.text = nil; } - (void)updateWithMessageModel:(MTUserMessageModel *)model { self.senderNameLabel.text = model.senderName; self.actionTextLabel.text = model.actionText; self.notifyDateLabel.text = model.notifyDate; } 

    里面用到的 label 生成方法如下

    + (UILabel *)mt_labelWithFont:(UIFont *)font andColor:(UIColor *)color { UILabel *label = [UILabel new]; label.fOnt= font; label.textColor = color; return label; } 
    第 3 条附言    2016-01-21 10:24:07 +08:00
    补个截图
    第 4 条附言    2016-01-21 10:51:38 +08:00
    6 条回复    2016-01-21 10:49:11 +08:00
    buydip
        1
    buydip  
       2016-01-20 22:38:42 +08:00
    贴代码看看?
    xi_lin
        2
    xi_lin  
    OP
       2016-01-21 00:13:36 +08:00
    @huoshanhui 已更新代码
    buydip
        3
    buydip  
       2016-01-21 10:03:09 +08:00
    奇怪,几乎一模一样的操作。
    xi_lin
        4
    xi_lin  
    OP
       2016-01-21 10:17:43 +08:00
    @huoshanhui 是啊。。
    lee0100317
        5
    lee0100317  
       2016-01-21 10:37:56 +08:00   1
    应该是无解 中文都会这样 纯英文不会
    xi_lin
        6
    xi_lin  
    OP
       2016-01-21 10:49:11 +08:00
    @lee0100317 试了下英文还真是。。原来如此,感谢!
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     2347 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 25ms UTC 11:30 PVG 19:30 LAX 03:30 JFK 06:30
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86