自定義了UITableViewCell疙剑,設(shè)置自己添加的label的backgroundColor為紫色,但是當(dāng)Cell被選中的時候践叠,lable的backgroundColor被改變了言缤。觀察一下label的backgroundColor在cell選中時的變化。
[RACObserve(self.lblSimple, backgroundColor) subscribeNext:^(id x) {
NSLog(@"%@",x);
}];
輸出結(jié)果為
UIDeviceWhiteColorSpace 0 0
UIDeviceRGBColorSpace 0.541 0.761 0.953 1
UIDeviceRGBColorSpace 0.541 0.761 0.953 1
UIDeviceWhiteColorSpace 0 0
UIDeviceRGBColorSpace 0.541 0.761 0.953 1
UIDeviceRGBColorSpace 0.541 0.761 0.953 1
這和cell的
- (void)setSelected:(BOOL)selected animated:(BOOL)animated;
- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated ;
密切相關(guān)禁灼」苄看看文檔,下面是
- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated ;
方法的文檔
Sets the highlighted state of the cell, optionally animating the transition
between states.
Highlights or unhighlights the cell, animating the transition between
regular and highlighted state if animated is YES. Highlighting affects the
appearance of the cell’s labels, image, and background.
Note that for highlighting to work properly, you must fetch the cell’s
label (or labels) using the textLabel (and detailTextLabel properties and set
the label’s highlightedTextColor property; for images, get the cell’s image
using the imageView property and set the UIImageView object’s
highlightedImage property.
A custom table cell may override this method to make any transitory
appearance changes.
注意
Highlighting affects the appearance of the cell’s labels, image, and background.
另外一個方法
- (void)setSelected:(BOOL)selected animated:(BOOL)animated;
也差不多弄捕。
但個人感覺選中時cell的表現(xiàn)還和tableView的allowsSelection,allowsMultipleSelection,allowsSelectionDuringEditing,allowsMultipleSelectionDuringEditing,editting等屬性相關(guān)僻孝,cell自身的selectionStyle的影響自是不必說。具體測試代碼守谓,有時間再補(bǔ)上穿铆。