Animated move of UIPopoverController? - ios

So, I have a setup where an UIPopoverController presents information at the cursor in a text view. When the cursor moves, I present it again. But this is jarring, and I'd like for the popover to move in a smooth, animated fashion. Will I really have to do that manually by using a series of presentFromRect calls, or is there a better way?

Unfortunately UIPopovers are not designed to be moved around like that.
The only way to do that without presenting it all over again is to write your own UIPopover replacement and animate its position using the standard CAAnimation or UIKit animation techniques.

If think you cannot do that without use presentFromRect. But if you really want to do this, create your own. Recreate the look of a popover controller using a UIView and track the touches. You can use an alternative like WEPopover.

Related

3dtouch to present(peek without pop) UIView like contacts app

I'm trying to implement 3D Touch feature that presents a summary of information (like Peek). But I don't want that it pops. I just want to preview the information like contacts app does with contatcs:
It only presents an UIView and doesn't deal with two levels of force (peek and pop).
How can I do something like this?
Ps.: I don't want to deal with long press gesture.
Introduction
Hello
I know this is a bit to late, probably, but in case someone else stumbles upon it: I certainly believe it is possible and I don't think its a "native behavior for contacts". Although it would not be as simple as the UIKit api for peek pop views. You would need to:
Steps
subclass UIGestureRecognizer (perhaps it may work with the UITapGestureRecognizer also), and register UITouches and use their force property.
Setup a UIViewController with transparent but blurred background around the edges (together with a modalPresentationStyle .overCurrentContext if i recall correctly), with your desired content in the middle (much like the peek view). Then add a UIPanGestureRecognizer to the center view for dismissal/sliding up the buttons.
And then create a custom animation transition for that UIViewController to be triggered once the force property of the registered UITouches from the subclassed UIGestureRecognizer is high enough. And then reversed once the force property gets low enough.
Concluding notes
I believe this is a bit of a tedious task and there might be a simpler way. For example, a simpler way using a 3rd party library for long pressure gestures (that registers size of the touch), but it would not give the same feel.

Insert blur layer between two existing view layers

I have a UIView with some buttons on it. What I would like to do, is add a full screen blur layer between the UIView and the buttons when the user does a long press on one of them. The visual appearance and location of the buttons shouldn't change.
What is the best way to do this? Also, if possible, I would like to avoid transfering the buttons from one view to another, as this might cause me a lot of trouble (the buttons are draggable).
You can use -[UIView insertSubview:belowSubview:] method to place blur view behind buttons.
I would suggest using Pop animation framework for animations.
As for creating blur view this looks good: https://stackoverflow.com/a/25706250/2754158
You could create a view with the blur effect, and use the method view.insertSubView(blurView, above|belowView: view)

How can I create a pop-up window using Cocos2d, SpriteBuilder and Objective-c?

So I'm trying to do exactly this:
http://blog.typpz.com/2013/12/09/ios-sdk-create-a-pop-up-window/
But since I am not using SpriteKit i can't use this exact method.
I imagine that there should be a way to create this same pop up window effect using sprite builders layer option maybe? Then animating it using some of the CCAction methods that exist. Im not sure though and don't really know how to go about figuring out.
Any help is appreciated.
A simple way to do this would be to create a CCLayer, as you said, and animate it.
Once you've created a CCLayer to the size of the "popup" you want, and then added whatever you want to put in it, you can then start animating it.
If you want to get a similar effect to the animation in the tutorial you linked, the best way would be to use a combination of CCActionFadeIn and CCActionScaleTo. Conveniently, Spritebuilder's animation set has both of these for use, and you can easily set up an keyframe animation from within Spritebuilder without too much code. (Make sure to name the animation sequence to something you can easily remember since you'll need to refer back to it when you start coding - I'd call it "PopupAnimation", or something like that.)
Once you've finished doing that, all you have to do is call the animation from your code. For example, if I have a CCButton whose selector is "showPopup", I would do:
func showPopup() {
self.animationManager.runAnimationsForSequenceNamed("PopupAnimation")
}
Assuming you've done everything right, the popup will now appear! But now you're stuck with the popup on the screen, and with no way out.
To fix this, make another animation sequence (I'll call this "RemovePopup") which will remove the popup from the screen. Add a button to your CCLayer, and set its selector to "hidePopup". From your code, you can then run:
func hidePopup() {
self.animationManager.runAnimationsForSequenceNamed("RemovePopup")
}
And now you have a "popup" window that you can animate!

Pretty user-interface with animated segue in Swift

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 :)

How to achieve smooth transition when image of button changes between states?

In iOS, we use the UIView animate block for tyo make chnages to properties of any control and that happens with a smooth transition.
Is it possible to achieve that when images of different state changes for UIButtons ?
What I can think of as of now is to manually change the image or state in animation block.
Is there a simpler way at the interface builder level or may be at code level so that I dont have to do this ?
Check out this Stackoverflow answer
link
I would subclass UIButton like in this answer so you only need to write the code once.

Resources