Posted By

LeeProbert on 08/13/10


Tagged

UIImage UIButton


Versions (?)

Who likes this?

5 people have marked this snippet as a favorite

umang_nine
bobbym245
sb
nsbuckner
cnathan


Using stretchable images in Obj-C buttons


 / Published in: Objective C
 

  1. UIImage *buttonImageNormal = [UIImage imageNamed:@"whiteButton.png"];
  2. UIImage *stretchableButtonImageNormal = [buttonImageNormal stretchableImageWithLeftCapWidth:12 topCapHeight:0];
  3. [doSomethingButton setBackgroundImage:stretchableButtonImageNormal forState:UIControlStateNormal];
  4.  
  5. UIImage *buttonImagePressed = [UIImage imageNamed:@"blueButton.png"];
  6. UIImage *stretchableButtonImagePressed = [buttonImagePressed stretchableImageWithLeftCapWidth:12 topCapHeight:0];
  7. [doSomethingButton setBackgroundImage:stretchableButtonImagePressed forState:UIControlStateHighlighted];

Report this snippet  

You need to login to post a comment.