views:

273

answers:

0

hi all,

I have a class defining a custom UIButton. I configurate a normal and selected state like this:

//custom image
UIImage *image = [UIImage imageNamed:@"customIconCreationBG.png"];
UIImage *stretchImage = [image stretchableImageWithLeftCapWidth:0.0 topCapHeight:0.0];
[self setBackgroundImage:stretchImage forState:UIControlStateNormal];

UIImage *imageSelected = [UIImage imageNamed:@"customIconCreationBG_selected.png"];
UIImage *stretchImageSelected = [imageSelected stretchableImageWithLeftCapWidth:0.0 topCapHeight:0.0];
[self setBackgroundImage:stretchImageSelected forState:UIControlStateSelected];

In another class I'm filling an array with custom buttons and i'm adding a button pressed method. It sets the selected state to TRUE

-(void)buttnPressed:(id)sender { NSLog(@"button pressed");

[[NSNotificationCenter defaultCenter] postNotificationName:@"unselectBGIcons" object:self];
HorizontalListIcon *pressedIcon = ((HorizontalListIcon *)sender);
[pressedIcon setSelected:TRUE];

}

The button switches to another background, which is great. Is there a way to animate this change ( fading in? ) because it's a bit hard now.

Greets