How to set a color to the entire cell which selected or checkmarked and reset to previous color while in unchecked in uitableview?I tried but it showing a background color for a sec.can any one please help me to code.
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- Could I create “Call” button in HTML 5 IPhone appl
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- Unable to process app at this time due to a genera
- Swift - hide pickerView after value selected
- Popover segue to static cell UITableView causes co
Ok, here I think you want to color your cell when selected and another color if unselected,leaving those selected cells with the previous color. So have an array states globally. In didSelectRowAtIndexPath :
And in cellForRowAtIndexPath :
In your header file make an object of NSIndexPath(let it be checkedIndexPath used here) and assign its property and synthesize it also.In your tableView's method cellForRowAtIndexPath use:
Now in your didSelectRowAtIndexPath use following:
Using this you will have your cell in red if selected and in green if unselected.
You can set the background color of the
UITableViewCell
and then on the click event the color will automatically change .
You can change the color of the selection by :-
For changing the textLabel color .