how to get a white light on a uibutton click - iphone

i just saw a code sample of uiwebview on icodeblog. It has a Address bar button. When i tap over that it displays a white light in the background of button. The image is flashy and looked good to me. Can some one tell me how to do that??
thanks

Set the showTouchWhenHighlighted property of your UIButton to YES.

Related

Adding image to UIButton makes it unclickable

I am learning to navigate and use the features of Xcode right now and I don't understand why adding an image to a UIButton through the Attributes Inspector makes the UIButton unclickable. When adding the image, it also resizes the button on the storyboard. I can't seem to find any answers online. Could somebody explain why this behavior occurs?
Before adding the image to the UIButton:
After adding the image to the UIButton:
Edit: and preferably how to fix it :D
The unclickable scenario you described is literally impossible unless you deleted everything in the connections inspector tab. In order for the image not to resize you should use autolayout in the bottom right. Set a constraint on width and height.

Button's background on ios7 is squeezed, ios6 ok

I just updated to XCode 5. Buttons in my app look OK in IB and on iOS 6 device, but on iOS 7 device they look like this (they should cover the whole black space):
I have images for both non-retina/retina.
I have no idea what to do, because I didn't change anything in code or IB.
EDIT:
Now I found out, if I change type of button from custom to system and set its background instead of its image, I get the correct size but I get some strange shadow over it.
EDIT2:
Now I set button's tint color to "clear color" and everything seems ok (shadow disappeared). Still not sure what has changed in iOS 7 related to this.
The Human Interface Guidelines specifically outline how system-style UIButtons work by default. It explains that a system button:
Has no border or background appearance by default ...
Supports custom decoration, such as a border or background image (to
add a custom appearance, use a button of type UIButtonTypeCustom and
supply a custom background image).
However the UIButton HIG page provides a little more information, specifically:
If you do not explicitly set a tint color, the button will inherit its superview’s tint color.
This explains why, after changing your button to UIButtonTypeSystem, you suddenly have to reset (remove) the tint colour. In iOS7, (almost) everything has a tint colour. A UIButtonTypeSystem is more appropriate for your needs now in iOS7 (a bit of a pain if there's a lot to manually change though...)
As to why the buttons shrink in iOS7... I agree with #Joseph's comment regarding UIViewController view frames in iOS7. Likely you have some set relation for the size of the buttons that does not play nicely when the ViewController's frame changes in iOS7 (see this SO question for discussion). As advised there, check out the iOS7 transition guide to see if anything you're doing in IB is going against the new iOS7-grain.
[button setBackgroundColor:[UIColor colorWithRed:(255.0/255.0) green:(180.0/255.0)];.
This is the right code for background, and if you are use image then use
[UIImage imageNamed:#".png"];

UIButton with changing images when pressed - but unattractive effect when changing them

I have a button that changes its image to different images depending on what modus we are in.
The images are set with:[modusBtn setImage:cx forState:UIControlStateNormal];
The images have round corners and the button is of Type "Custom".
Now when the button is pressed one can see another image in the upper and lower edge background.
Really weird - the buttons ALL have round corners - but for example when the blue modus is on and shows the blue image and one presses the blue button now - one can see red little edges only on the left two corners.
I already played around with all the button attribute settings in IB, but no luck.
Did anyone have a similar experience when changing button images?
So far all my button images where 100% rectangular and did not have round corners - therefore I never experienced this before.
Many thanks!
Use this UIButton's propriety for your button.
avatarButton.clipsToBounds = YES;
Whenever you set an image for custom button make sure to set
yourButton.backgroundColor=[UIColor clearColor];
The effect was happening as your button was using default background transitions during changing the state.

I have a UIButton subclass that I have set an image to in IB, and strangely about 1/3 of the button won't respond to touch! What's going on?

As described, I have a UIButton subclass, that I am designing in IB. I have set the button subclass to a UIView, and set an image to the button as well. I have set a UILabel beneath the image, attempting to give it the Finder look. Everything works great, except for the fact that the right 1/3rd of the image won't respond to touch!
It is the strangest thing. The button bounds are set to encapsulate the entire image, but that right 1/3rd won'r respond.
Has anyone seen this before? Does anybody know what's going on?
Thanks

How does iPhone draw controller?

I'm a newbie in iPhone development and now encounter a problem:
I want to add a small hotspot on a large image and simply came up with the idea that I can add a button in that area setting alpha 0 to hide the button. Unfortunately, the phone does not response click events any more. Instead, if I increase the alpha, I can receive click events without any problems. So I wonder in which order does iPhone draw controller on the screen. Is it because my background image is drawn after the button if I set alpha of button too low, so the click event is intercepted by the background image?
Any hints will be highly appreciated. Thank you all in advance!
Best Regards.
Set the button's style to Custom; the button will not be drawn, but should remain fully active.
The problem is not the order in which the views are drawn, it's rather that if a view's alpha is 0 it does not receive touch events. it's like the view is not there at all.
but you don't have to set the alpha to 0 on the UIButton, you can simply make it a Custom button instead of a Rounded Rect button. it'll be invisible and still work.