I am new to iOS development and not aware of lot of features which iOS provides so need your help in building new UI.
Now my requirement is I have A - B - C three controllers where B is homescreen, I want user to pan (pan I mean to say next view controller should come w.r.t to users finger touch ) on the right edge or left edge to go to their respective ViewControllers from B and can come back
along the same line ..
This is my basic structure, I know how to do it with the swipe but then it is wont fulfill my requirment , also to slide the new screen w.r.t to finger is also there.
Try using SWReavelViewController. It is a very easy to use component and will be suited for your solution.
You can find the code HERE
you could get your hands on ViewDeck. It got some more offering than SWReavelViewController. Check this ViewDeck. If anything else is there let me know.
Related
I'm building a to-do app in Swift as a practice project, and would like to make it so that when the user swipes from left to right on a task in the list, my "completed" boolean in the task becomes true. Similar how in the native Mail app, swiping right on an email marks it read.
I came across the onDelete() function provided by Apple that handles right to left swipes, but as far as I can tell there's no code for left to right swipes. I think that makes it ok to implement a left to right swipe, but I can't find any examples of how to do so in SwiftUI. I think this question was asked once on Stack Overflow here, but the answer only pertained to deleting and moving.
that called gestures and for swipe gesture you can see the documentation here - https://developer.apple.com/documentation/uikit/uiswipegesturerecognizer
and if you don't want to make it from scratch then you can use library for it and the kind of functionality you want go for this library SwipeCellKit here is link https://cocoapods.org/pods/SwipeCellKit with this you can easily make the kind of functionality you want.
iOS 15
You can define any number of actions with .swipeActionis modifier for either leading, or trailing side of the cell with the given view as the label and give them a tint color like:
Suppose there is button on first screen of an app which is connecting to second screen(i.e on click on that button second screen will come) and also to a function on first screen class .
Now my question is what is the flow first function||second screen will executes?or both simultaneously will execute.
You have to know that iOS Applications usually use MVC pattern.
So for your example, you have the View (V), containing the design, your button etc..
And the Controller (C), implementing the logic.
The answer is : You can decide which one comes first, just depends how you implement it.
But I don't really understand the logic in your example, can you be more specific.
You should try to make 1 interface element for 1 purpose.
I'm looking to recreate the functionality that's show in this video for the picture:
https://www.youtube.com/watch?v=zEREoIcoQHE
A long press is done, a view appears, and when the user swipes up far enough, the options come up at the bottom. If the user continues to drag up higher and then lets go, the main view animates to bounce back down to the middle of the screen. If the user swipes all the way down, the view animates away.
I recognize there is a lot going on here and a lot of different pieces and that this is a very broad question. I'm more or less looking for a place to get started with it. The only thing I really recognize here is I guess a scrollview. I know how to do all of the basic stuff with presenting and dismissing the different views, but the dragging and the scrolling and the snapping back into place is where I'm not sure where to begin.
Is that all just scrollView code I need to learn? For example I guess there's a way to detect when the scroll has been scrolled far enough up to trigger presenting the options view. What is making the view bounce back into place after dragging up and releasing? etc.
What tools are used to achieve this kind of behavior?
If I am not mistaken thats the "Apple's" 3D touch APIs magic ✨
Check out their documentation
You might be interested in :
ViewControllerPreviews: Using the UIViewController previewing APIs, which demonstrates peek (preview) and pop (commit), as well as peek quick actions
Reference: https://developer.apple.com/library/content/samplecode/ViewControllerPreviews/Introduction/Intro.html#//apple_ref/doc/uid/TP40016546
When swiping between stories in Instagrams new feature "Stories" (you know that cube-like transition when going from one story to another) I can't manage to understand how they do it!
First of all, if you dig deeper into the functionality you find that it works exactly like the UIPageViewControllers transition:
- It bounces when swiping fast from one view to another.
- You can pause the swipe in the middle of the transition by touching the screen.
The developing team couldn't have used a solution based on the more known workarounds out there, e.g:
https://www.appcoda.com/custom-view-controller-transitions-tutorial/
Because as far as I know my two statement above is not possible to achieve with anything else than the PageViewController.
This leaves me thinking that the Instagram Developer Team gained access to a new transition style for the PageViewController, also known as Cube-scroll, or is it a workaround that I'm not aware of?
Any ideas?
I took a shot at recreating this functionality a while back. You can check the source code on GitHub: https://github.com/oyvind-hauge/OHCubeView
I'm using a scroll view (with paging enabled) and, for each subview I'm manipulating these as a function of the given view's current x-offset in the scroll view. The actual animations are done on each subview's layer using Core Animation (more specifically, transforming an identity matrix, given by CATransform3DIdentity, using the method CATransform3DRotate).
The shadow effects are also applied to the subview's layers (view.layer.opacity), with the amount of shadow determined by how much of the view is showing on screen.
My implementation solves both of your concerns (bounces when swiping, can pause swipes). I'm sure this could have also been implemented using the a UIPageViewController, but I hate working with those.
I think you are overthinking the controller's part here. The effect can easily be achieved using a CATransformLayer and three-sided cube-like view structure, where there is one view which aligns with the screen plane, and two others rotated -90 and 90 degrees on their y axis. Then, getting a pan gesture to rotate the scene. After a successful 90 degree turn (in either direction), you can either quickly reset the scene (so that keeping on rotating appears as if continues, but actually the camera shifted back to initial position) or you can have a full 360 degree rotation, and just update previous and next "pages". A single controller can handle this scene. If you prefer to have each page as a controller, it is possible, you can still use one controller for the scene, and then use the page controllers as child controllers, and setting their views as described above.
See this article for more information on CATransformLayer. Their example already creates something that is quite close to what you need.
I want to make a pretty interface. So after reflexion, I decide to make a pattern with to axes but with some essential points. The red screen is the primary screen, all start by this one.
We can only make this two move : red to another color and another color to red. And change are made with GestureRecognizer.
I also want to switch view by seeing the two at the same time. Obviously, it's following my finger and I can stay in this state.
Do you think that 5 viewController witch are all load at the start and we came to these with pretty segue (maybe custom) is possible ? And if yes, do you have an idea of how to make this ?
As a first thought I think you want to make a custom view controller navigation controller. Like UINavigationController, UITabBarController or UIPageViewController.
I'd also use a scroll view over a gesture recogniser maybe?
Either way it's gonna be a lot of work which means there are many many different ways to do it.
It sounds like you have a decent idea of how you want it to work. Give it a whirl and see what happens. I reckon you can have a decent bash at it.
If you get stuck let us know and we'll try to help :)