मेरे पास एक कस्टम UITableViewCell
है। कस्टम टेक्स्ट के साथ इसमें 3 कस्टम लेबल हैं।कस्टम टेबल दृश्य सेल चयन फ़ॉन्ट रंग
जब मैं सेल पर टैप करता हूं, तो मुझे उन सभी लेबलों का पाठ रंग सफेद होना चाहिए। ईमेल एप UITableViewCell
व्यवहार की तरह।
इसके लिए, मैंने इसे कस्टम सेल क्लास में लिखा था।
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
if (self.selected) {
_subjectLabel.textColor = [UIColor whiteColor];
_messageLabel.textColor = [UIColor whiteColor];
_usernameLabel.textColor = [UIColor whiteColor];
}else {
_subjectLabel.textColor = [UIColor blackColor];
_messageLabel.textColor = [UIColor grayColor];
_usernameLabel.textColor = [UIColor blackColor];
}
}
मैं इसे प्राप्त करने में सक्षम था। लेकिन यह उतना आसान नहीं है जितना कि यह ईमेल ऐप में है। रंग थोड़ी देर के बाद ही बदलता है। UITableViewCell
की कौन सी विधि को इस कोड को रखने के लिए ओवरराइड करना चाहिए। मुझे नीचे दिए गए विकल्पों के बारे में पता है, लेकिन वे कस्टम सेल में कस्टम लेबल पर व्यवहार नहीं करते हैं।
typedef enum {
UITableViewCellSelectionStyleNone,
UITableViewCellSelectionStyleBlue,
UITableViewCellSelectionStyleGray
} UITableViewCellSelectionStyle;
धन्यवाद। इसने काम कर दिया! – Anand
बस एक छोटा अनुस्मारक, यदि सेल एक कस्टम है, तो आप xib खोल सकते हैं और विशेषता निरीक्षक के तहत, आप "हाइलाइट" रंग सेट कर सकते हैं। –