iPhone Fall Down button (Animation) - iphone

Is it possible do something like this ?
When I click on the button I need the following animation: button to set some alpha filter and starts to fall down as indicated by the arrow, it will disappear on tab.
Can you tell me how to do this ? Thanks a lot ...
Here is image url: http://img534.imageshack.us/img534/8149/screenqx.jpg

It's definitely possible, but there are some issues you have to overcome. One is that UIBarButtonItem isn't a UIView. One way is to loop through the subviews of the UIToolbar or UINavigationBar. Another way is to figure out the position of the button. Another is to get the view using private api if you're not submitting to the AppStore.
Once you have the view, you can move it to the superview of the UIToolbar or UINavigationBar or you can create a view on top of that (and hide the real UIBarButtonItem since you're done with that). The latter is more difficult because mimicking the look of the default bordered UIBarButtonItem isn't easy.
Now you need to get the center of the UITabBarItem somehow. You can either use private api or you can loop through the subviews.
Create a CGPath using Quartz functions or using UIBezierPath. The start point will be the center of the button and the end point will be the center of the UITabBarItem.
Create a CAKeyFrameAnimation and attach said CGPath.
Create a CABasicAnimation to animate the opacity.
Add both to a CAAnimationGroup.
Attach the animation group to your button view's CALayer.
Make sure to also set the position and the alpha in order to prevent the view from jumping back to its original position after the animation.
Once you attach the animation group, the animation should start, so make sure you're doing all of this in the button's selector method.

You can't really move it from view to view, as your views could clip and then you'd get frames with only a partial image. Probably the best thing to do is to create a view on the fly which covers the whole screen, copy the button image into the view at the original point, remove the button from the original view, then animate that image to where you want it to go, then add the button to the final destination.

Related

Adding UIButton to UIImageView within UIScrollView on Swift

I am writing an application for an event my organization is hosting using Swift. I have an image with the floor layout and want to add buttons to select locations (such as bathrooms, entrances, exits, emergency sections, etc) so that people can click them and information about the location pops up.
I currently have an imageview with the floor layout within a scrollview to allow the user to zoom in and out of the image. When I try to add buttons to the scrollview they don't stay relative to the image when zooming in and out, nor do their size change. I have tried adding constraints on to make the location stay the same when zooming in and out.
It also won't let me relocate the button on the storyboard to be a subview of the imageview. Looking up similar solutions says to add the button programmatically as a subview of the imageview but then it'd be really hard to put the 100+ buttons in the right location. Any suggestions as to how to go about this?
you have no other choice instead of adding by code.. because from code you can add as subview of image view , whereas Storyboard wont add buttons as subviews of imageView, but it will add buttons as subview of Scroll View

Swift Animation - Circle behind button

I'm trying to add some animation in my app. I would like to show a circle when I tap a button.
I don't really know what could be the best way to do that.
Do I have to create on the storyboard a view with a background, and I add corner radius and use the isHidden property ?
Do I have to create the circle programmatically ? Maybe better because I have many buttons ?
BEST WAY:
DEMO
1. Assets Used
Set Default Image on Default State of UIButton
Set Highlighted Image on Highlighted State of UIButton

UIPopoverController in application window

I am creating a UIPopoverController from the application delegate and I want to center it on the window, how ca I do that?
You can specify the rectangle that it is anchored to when you display it. Just specify an rectangle and direction that guarantees it will be displayed in the position you want.
It does sound like you may be doing something that would be best done by presenting a custom UIView as a new subview instead of using a popover. The popover will always have the little arrow coming off the side.

Shadow inside UIView

I am working on iPhone application development and have come across shadows of UIView.
I know how to show shadows to a UIView but what I am actually interested in is to drop shadow inside the UIView.
Like when I set shadow properties of a UIView the shadow is dropped behind the view. I want it to come over the view so that the view looks as if it is pressed inside.
Example of such view is UITextField with roundedRect styling.
Thanks,
It depends a lot on the final effect you want to achieve.
The easies way would be a custom image with a prebacked shadow as background. This will give the illusion of a recession in the surface of the view. You can then add subviews to it as usual.
Alternatively, you can override the drawRect: method and draw the view as you like there, "inverted drop shadow" included.

UIBarButtonItem in middle of navbar?

I have created a flexible navigation bar in my app that will show custom buttons on the left, right, and in the middle. So far I have got working:
Right/Left/Middle - Custom Image and/or Text
Right/Left - Normal looking button with custom Image in it
Right/Left - Normal looking button with custom Text in it
By 'normal looking' I mean the default UIBarButtonItemStyle- just a nice shiny button.
My question is, how can I achieve the same look in the MIDDLE of the nav bar? I can do custom/text images by just creating a custom UIButton, and on the right / left I create a UIBarButtonItem from it, but in the middle I just add the UIButton view as a subview of the navbar.
I can't add a UIBarButtonItem to the navbar as a subview, and any UIButton I create doesn't look like a UIBarButtonItem.
The only workaround I can think of is to use a stretchable custom image that I steal from a screenshot. I'd rather avoid doing it this way. Am I missing something?
*********** UPDATE **************
The open source library Three20 will allow you to create UIButtons that look like UIBarButtonItems. Then you can add them to the bar view either by placing manually as a subview or by setting the title view.
I never understood why they didn't make UIBarButtonItems derive from UIViews (or even better, UIButtons) so they could be used elsewhere.
Sounds like you're on the right track, but need better artwork :-) You can get a large number of iPhone UI components in a Photoshop .PSD file from here. They have pre-rendered bar buttons which you can use as a base for a standard UIButton image. If you have Photoshop (or a decent drawing program) you can stretch the buttons from the middle to fit your size without getting the corners distorted. Just add the label and you should be good to go.
Put a flexible region on the left and right, they will offset each other causing anything between them to be centered