ios - When cell is selected, the backgound color of the button will change and then recorver -
i have customize uitableviewcell , there button within it, when set background color of button color other default color
(which [uicolor whitecolor]
), when cell selected, background color of button change , recover when selection highlight of cell disappear.
how happen , keep button's background color when cell selected?
i recommend inspecting hierarchy of views you've got table view cells. can done: run app on simulator -> click "debug view hierarchy" (see 1st image attached) -> play around inspector (see 2nd image attached).
update: after digging while got following (please see 3 screenshots below explaining situation):
as can see, there's internal call clears background colors of cell's subviews named _setopaque:forsubview:
having said, if want ensure background color of button remains same should implement selection mechanism of cell in following way:
- (void)setselected:(bool)selected animated:(bool)animated { [super setselected:selected animated:animated]; // here comes custom color (it's assumed mybutton binded iboutlet self.mybutton.backgroundcolor = [uicolor greencolor]; // or whatever else }
it unkind of uikit. hope you.
Comments
Post a Comment