I found a great design in an apparently rather famous app called Zenly, they use a view on the bottom of the screen to add extra content to the user experience. I need a view very similar to this one. Unfortunately, I have no idea at all how to get exactly this rounded off shape that the view has on its top. How would I do that? Here's a screenshot.
相关问题
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
- “Zero out” sensitive String data in Swift
- SwiftUI: UIImage (QRCode) does not load after call
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- Using if let syntax in switch statement
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- Enum with associated value conforming to CaseItera
- Swift - hide pickerView after value selected
- Is there a Github markdown language identifier for
hum eu.., I'm quite new to IOS but I think that you can do it using Constraints animations, UIGestureRecogniser, and (view.layer.cornerRadius) let me try.
ok let us star will you?
Firstly ,here is the result : https://streamable.com/cv91a
now on the attribute inspector search for "MAP KIT VIEW" and add it half the screen
see screenshot here
now still on the attribute inspector search for "View" then place it so that a part of it overlaps the MAP KIT VIEW then set its color to the desired color (if you want the same color as the one on your pic, use the colorPicker icon and pick that color from the image)
see screenshot here
once it is done place the constraints on the "MAP KIT VIEW" and on the "blue View" (on the blueView you have to make sure to place a constraint from the top of the screen (see the pic you'll understand))
see screenshot here
now connect the BlueView to ViewController.swift as a UIView! and also connect the top constraint to the code (look at my previous image)
now add the buttons, the labels as per the image you provided us and connect all of them inside viewController.swift
now let me explain the logic that we will be applying from here
1) we will set the corner of the BlueView and the button with the "cornerRadius" property of their respective layer
2) we will use uiSwipeGestureRecogniser to recognize a swipe up and down on that blueView then act accordingly
3) we will animate the view everytime a change is detected (actually we will be animating the top constraint we connected to our code earlier)
Note before we continue: animating in IOS is another notion that you're supposed to know, if you don't know animations, you can still follow along with me but at the end of this tutorial, I would suggest you go on https://www.raywenderlich.com/category/ios then search for the basics of animating.
Now let's go on the storyboard: on the attribute inspector search for "Swipe Gesture Recognizer" and drag it 2 times on the blue view in order to have 2 gestures on It
rename the first Swipe Gesture Recognizer to SwipeUpGestureRecognizer and the other one to SwipeDownGestureRecognizer
now the tricky part to not miss: you have to set the delegate of both the gestureRecognizer to the BlueView (see the pic, most of the time you just drag and choose delegate )
see screenshot here
now connect the 2 gestureRecognizers to viewController.swift as an @IBAction you'll get something like this :
Now it is time we get the corners to be like in the picture : for that we will use the layer properties and change their corner radius , we do it on viewDidLoad . here is the code :
now add this code inside both the functions and make sure that the value of the constraint.constant is different
some explanations : Uiview.animate(_) is used to animate elements(uiViews, uiButton etc..) in IOS; as I said before there are many types of animations. Here we will be using what we call "Spring Animation" ; the code is pretty self-explanatory, the parameter options is an enumeration of behavior (i guess it's called like that ), here I used ".curveEaseOut" then inside the closure (what is after animation: ) I used self.view.layoutIfNeeded() to enable the animation to work smoothly, without it you'll be having a weird behavior
Here is my full code
import UIKit
I Guess it is all you have to do . I'm sorry If it is not really nice, I'm still too new to tutorials, explaining, and swift so I hope I was clear enough . here is a video of it https://streamable.com/cv91a (again).
note that it is not a polished work just something I made to explain, you'll have to customize it according to your need and polish everything else yourself