When you open Mail on an iPhone and tap Edit, select an email and tap Move, a UITableView appears with all the folders you can put the mail in. At the top is a transparent view that shows the email you selected. When you move your finger down, the view stays in place, when you move it up, the cells are visible through the transparent view.
How did apple configure this view? I thought of two ways, but they both don’t work:
-
The view is returned as the header view of the
UITableView. Doesn’t work because the view stays at the top even if the table view is moved down. -
The view is static at the top, the frame of the table view starts at the bottom of the transparent view. This doesn’t work because when the table view is moved up, it is visible through the transparent view.
Any ideas on how to recreate this effect?
You need to create your transparent view and then add it as a subview to the view controller so it’s a sibling of the
UITableView. You would do this in theviewDidLoad()method.You could also setup your view using an XIB, but I’ll leave that as an exercise for you.
Edit: Removed the requirement for the the
UITableViewdelegate methods and custom header view by using thecontentInsetproperty instead.Note: see additional comments below.