I know about UITableview: How to Disable Selection for Some Rows but Not Others and cell.selectionStyle = UITableViewCellSelectionStyleNone
, but how do I make a cell (or any UIView
for that matter) appear disabled (grayed-out) like below?
相关问题
- Custom UITableview cell accessibility not working
- UITableViewCell layout not updating until cell is
- Showing a checkmark accessory view move the table
- Setting the inputAccessoryView of a UITextField to
- How to put ActivityIndicator inside UIImage inside
相关文章
- UITableView dragging distance with UIRefreshContro
- Popover segue to static cell UITableView causes co
- TransitionFromView removes previous view
- ios7 new pan gesture to go back in navigation stac
- Navigation bar disappears when typing in UISearchC
- Inserting row and deleting row simultaneously. UIT
- Swift Change the tableviewcell border color accord
- UITableView ContentInsets scrolling content horizo
A Swift extension that works well in the context I'm using it; your mileage may vary.
Swift 2.x
Swift 3:
Now it's just a matter of calling
myCell.enable(truthValue)
.You can just disable the cell's text fields to gray them out:
Swift 4.x
Great extension from Kevin Owens, this is my correction to working with Swift 2.x:
Swift 3:
I have created following extension to Enable/Disable UITableViewCell, it is very convenient to use it. Create UITableViewCell Extension with "UITableViewCell+Ext.h" contain following in it.
"UITableViewCell+Ext.m" contain following in it.
How to Disable Cell:
How to Enable Cell:
Hope it helps you.
Thanks to @Ajay Sharma, I figured out how to make a
UITableViewCell
appear disabled:And then, to actually disable the cell:
Try using a small trick:
Just set the alpha of the cell. Put some condition as your own requirements & set the alpha.
If it does't work,the way you like it to be then, Use second trick,
Just take an image of the cell size having gray background with Transparent Background, just add that image in image over the cell content. Like this:
Although I am not not sure about the way,but this will surely fulfill your requirement.This will give a kind of illusion in user's mind that the cell is Disable. Just try using this solution.Hope that will solve your problem.