tags:

views:

1150

answers:

2

I have been gone through following link


http://stackoverflow.com/questions/351919/how-to-programatically-highlight-a-uibutton

in first two lines of their code, i found

UIImage* normalImage = [infoButton imageForState:UIControlStateNormal];
UIImage
highlighted = [_infoButton imageForState:UIControlStateHighlighted];

It seems that they have used multiple images, for their infoButton.


What i need is explained below,

I have an application with many buttons,

Every button has different images & that makes my application very huge in size.

If I make different images for normalState & highlightedState my App size goes to double.

So, i need some ideas like blur, or size down of button or image, or alpha down, for my button image,

i don't know the code & that's my Question.

so, how to animate/highlight the button on tapped in iPhone?

Thanks in advance.

+2  A: 

Ok ! I got one solution.

That is very much similar to my requirement. Yes, There may be other solutions,

i find which is nearer to my request.

select your UIButton in view & set Button Attributes

-> check mark on -> shows Touch on Highlight.

sugar
+1  A: 

First, "very huge in size" is a relative thing. Is it over the 10 MB limit that prevents download through the network? If not, maybe you shouldn't worry about it.

Second, have you tried saving the images in a form with better compression, such as JPEG?

Third, are these "different images" substantially different, as in "In one state it looks like an elephant and in another state it looks like the Taj Mahal"? Or is it a matter of needing different "elephant states"? It sounds like the latter.

One possibility is to set some of the button's properties to activate different drawing behavior. Look at:

button.reversesTitleShadowWhenHighlighted OR button.adjustsImageWhenHighlighted

or try varying

  • (void)setTitleColor:(UIColor *)color forState:(UIControlState)state;

They have actually provided quite a few options.

Amagrammer