How to set clear background in table view cell swipe action?
You can just set the alpha value to 0 for background color of the action:
let modifyAction = UIContextualAction(style: .normal, title: "", handler: { (ac:UIContextualAction, view:UIView, success:(Bool) -> Void) in
print("Update action ...")
success(true)
})
modifyAction.backgroundColor = UIColor.init(red: 0/255.0, green: 0/255.0, blue: 0/255.0, alpha: 0.0)
How to change cell color on swipe left in tableView in swift
func tableView(_ tableView: UITableView, willBeginEditingRowAt indexPath: IndexPath) {
let cell = tableView.cellForRow(at: indexPath)
cell?.contentView.backgroundColor = .red
}
func tableView(_ tableView: UITableView, didEndEditingRowAt indexPath: IndexPath?) {
if indexPath != nil {
let cell = tableView.cellForRow(at: indexPath!)
cell?.contentView.backgroundColor = .red
}
}
iOS - How To Give A Peek At The Swipe To Delete Action On A Table View Cell?
I'm pretty sure this can't be done. The swipe actions are contained in a UISwipeActionPullView
, which contains UISwipeStandardAction
subviews, both of which are private. They are also part of the table view, not the cell, and they're not added unless a gesture is happening, so you can't just bump the cell to one side and see them there.
Outside of UI automation tests, it isn't possible to simulate user gestures without using private API, so you can't "fake" a swipe and then show the results to the user.
However, why bother doing it "properly" when you can cheat? It shouldn't be too hard to bounce the cell's content view slightly to the left, and bounce in a red box (not so far that you can see text, to avoid localisation issues), then return to normal. Do this on the first load of the table view, and stop doing it after N times or after the user has proven that they know how this particular iOS convention works.
Image in TableViewCell swipe action
In the second image, the green is the UIContextualAction's backgroundColor
and the white is the tintColor
.
The image is treated as a template image — that is, its colors are ignored, and instead it is drawn transparent where your image is transparent, and drawn opaque with the tintColor
where your image is opaque.
So, basically you would need to reverse your settings: set the background color to white and change the tint color to the darker green shown in your image. Setting the tint color is not easy, but you could do it, for example, in your app delegate didFinishLaunching
using the appearance proxy, as suggested here (though this may have other unwanted side effects):
UIImageView.appearance(
whenContainedInInstancesOf: [UITableView.self])
.tintColor = // whatever that green is
Related Topics
Swift: Protocol VS. Struct VS. Class
How to Give Cornerradius for Uibezierpath
How to Crop a 4*3 Image in Photolibrary or Camera in Swift
How to Get All the Sundays in Array of Date iOS
Get Latitude and Longitude Center of Google Map
How to Delete an Image from Photolibrary After I Pick It Up Using Uiimagepickercontroller
User Notification Request Always Come with Default Action Identifier
In iOS Avplayer, Addperiodictimeobserverforinterval Seems to Be Missing
It Is Possible to Know If a String Is Encoded in Base64
API to Capture Live Photos in iOS9
How to Use Nsuserdefaults to Store an Array of Custom Classes in Swift
Rotate a Imageview Around a Pivot Point in iOS
How to Get the Nondecoded Attributes from a Decoder Container in Swift 4
Xcode 6 Swift Wkwebview Keyboard Settings
Get the Value of Variable Out of Closure Swift