Lists: Improving the User Experience Programmatically
Professional iOS User Interface Enhancement Tutorial
Key UI Improvements Covered
Spacing Optimization
Learn to dynamically calculate spacing using UIEdgeInsets for better visual hierarchy between interface elements.
Cell Background Customization
Implement custom background images and colors for table view cell selection states across multiple screens.
Typography Enhancement
Apply conditional font weight changes to completed list items using ternary operators for better user feedback.
This exercise builds on previous work. Complete exercises 5A-6C first, or use the provided Lists Ready for UX Improvement starter project from Desktop > Class Files > yourname-iOS App Dev 2 Class.
Project Setup Process
Launch Development Environment
Open Xcode and ensure Lists.xcodeproj is loaded. If closed, navigate to File > Open and locate your project file.
Verify Prerequisites
Confirm completion of exercises 5A-6C or open the provided starter project from the Class Files directory.
Test Current State
Run the Simulator to observe the current UI before implementing enhancements.
Use viewDidLoad for one-time setup like loadLists(), but use viewWillAppear for code that needs to run multiple times as the interface changes, such as spacing adjustments that depend on dynamic content.
listsTableView.contentInset = UIEdgeInsets(top: listsTableView.frame.height/38, left: 0, bottom: 0, right: 0)
Cell State Background Comparison
| Feature | Default State | Selected State |
|---|---|---|
| Background Image | CellDeselectedBackground | CellSelectedBackground |
| Background Color | Default Gray | Custom RGB (250,247,235) |
| User Experience | Generic appearance | Brand-consistent styling |
When using RGB values from design tools, remember to divide by 255 for iOS UIColor. Example: Red 250 becomes 250/255 in displayP3Red parameter.
Table View Cells get recycled but their content doesn't retain state. Always set font properties in both the cell's checkButtonTapped method AND the parent Table View's cellForRowAt method to ensure consistency.
itemNameLabel.font = item.checked ? UIFont.systemFont(ofSize: 17, weight: UIFontWeightBold) : UIFont.systemFont(ofSize: 17, weight: UIFontWeightRegular)
Custom Navigation Controller Implementation
Create Navigation Controller Subclass
Use File > New > File, select Cocoa Touch Class template, and create a UINavigationController subclass named NavigationController.
Add Background Image
Set navigationBar.setBackgroundImage with a 9x9 pixel tiled image and enable translucency for proper visual effect.
Connect in Storyboard
In Identity Inspector, set the Navigation Controller's class to your custom NavigationController to apply the styling.
The NavigationBarBackground is only 9x9 pixels but tiles seamlessly across the entire navigation bar. This technique saves memory while providing consistent styling across all screen sizes.
Key Takeaways

