Bird
0
0

How can you customize the background color of a UIContextualAction to blue for a custom swipe action?

hard📝 Application Q9 of 15
iOS Swift - Lists and Data Display
How can you customize the background color of a UIContextualAction to blue for a custom swipe action?
AOverride the <code>draw</code> method of UIContextualAction
BSet the <code>tintColor</code> of the UITableViewCell
CSet the <code>backgroundView</code> of UISwipeActionsConfiguration
DSet the <code>backgroundColor</code> property of the UIContextualAction instance
Step-by-Step Solution
Solution:
  1. Step 1: Identify UIContextualAction customization options

    UIContextualAction has a backgroundColor property to set the button color.
  2. Step 2: Apply backgroundColor for custom color

    Setting backgroundColor to UIColor.blue changes the swipe button color to blue.
  3. Final Answer:

    Set the backgroundColor property of the UIContextualAction instance -> Option D
  4. Quick Check:

    Customize swipe button color via UIContextualAction.backgroundColor [OK]
Quick Trick: Use backgroundColor property to change swipe action button color [OK]
Common Mistakes:
  • Trying to change cell tintColor instead
  • Attempting to override draw method (not supported)
  • Setting backgroundView on UISwipeActionsConfiguration

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes