Stocks App Style View Presentation

How do I create a view to stick at 3 different positions on swiping up (or down)?
Referring to “Business News” part in the screenshots below.

1 Like

Hi ,

It is actually fairly easy.

Here is the code:


//Swipe right
 func tableView(_ tableView: UITableView,
                   leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration?
    {
        
//Add more UIContextualAction for more actions.
        let editAction = UIContextualAction(style: .destructive, title:  "Edit", handler: { (ac:UIContextualAction, view:UIView, success:(Bool) -> Void) in
         
 //your code here
            
            success(true)
        })
        
       
        return UISwipeActionsConfiguration(actions: [editAction])


//Swipe left to  delete example

func tableView(_ tableView: UITableView,
                   trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration?
    {
        let modifyAction = UIContextualAction(style: .normal, title:  "Delete", handler: { (ac:UIContextualAction, view:UIView, success:(Bool) -> Void) in
            
//Your code here
               
               success(true)
           })
           modifyAction.image = UIImage(named: "trash")
           modifyAction.backgroundColor = .red
           
           return UISwipeActionsConfiguration(actions: [modifyAction])
       }

Blessings,
—Mark

Hey Mark, thanks for the answer. But, I was referring to swiping up action on the view. The screenshots represent 3 different positions that the view can be swiped up to. How can I achieve that?

Ops sorry, actually that is even easier.

I don’t use the Stock app so was not sure until I opened it.

These are just new views presented Modally, which is new in iOS 13.

If they swipe up from the bottom, they are the new modals which proved more info to the current screen. At least that is how Apple says what they are supposed to represent.

A Show (push) or Show Detail (replace) are supposed to show a new context and come into view from the right side of the screen.

Blessings,
—Mark

1 Like

Got it. “…even easier…” I was expecting that to be in the answer :joy:. Thank you so much!

Is there any way I can do it using Storyboard (not SwiftUI)?

You bet. I would not even know how to do this with SwitUI yet! :slight_smile:

Create a new viewController in the storyboard and add the content you want.

Then create a Story Board Segue either control dragging from the original VC to the new VC or from a button on the original VC to the new VC and choose the “kind” f the segue to present modally, or present popover.

Build and run and there you have it!

Blessings,
—Mark

Thank you @FoundationSW