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
Related
I wanna to make a button so that it has the shape of a stone/ rocket (i.e. irregular shape not a rectangle, square ... etc)
, i wanna to make it also highlighted/bordered with the same shape , i tried a UIButtonTypeCustom but it did not give me what i want .. so anyone has any help or idea, don't be skimpy.
Thanks in advance.
Use UIButtonTypeCustom but also add your custom assets for the look of the button.
Typically you will set the background image of the UIButton to some image you want (your rock, rocket, etc) for each state of the button (Normal, Highlighted, Disabled…).
Simply add the images in your Xcode project, then set the background image for each state of your UIButton directly in your XIB (using the Object Inspector panel on the right), or via code using the setBackgroundImage:forState: method.
I have to display a UIButton like in the following image. Button size can be varying. How can I do that? Please suggest a way.
If you just want a simple outline (it's a little hard to tell from your image what the button is), create the button with UIButtonTypeCustom (so you get a blank slate) then set its background color to be black. next, get the CALayer of the button (through the layer method) and set the borderColor and borderWidth properties as desired.
make a view and set it's color a bit darker than your desired button color, then make a button a bit shorter than the view size and place it as your fit position, check n tell me if it helps youe
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.
I have a UIButton that's 90x90 in size and I would like it to glow when tapped. Using showsTouchWhenHighlighted will make it glow but it's glowing out of the center of the button and for a small radius only. This might work well for a small button like the info button, but for my button size, it's not. Is there anything I can do to make it glow from the outer perimeter of the button before I resort to designing a highlighted state?
I can think of 2 ways to do what you want:
Use different highlighted background image for your button's highlighted state,
Use CoreGraphics to draw the glow effect in your button's IBAction (touchDown is a decent place).
This is assuming you want some kind of custom glow effect of course - UIButtons already naturally have a highlighted effect when touched.
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