views:

498

answers:

1
UIButton *ticketButtonObj=
    [[UIButton alloc]initWithFrame:CGRectMake(140.0f 100.0f, 390.0f, 40.0f)];   
UIImage *buttonicon1=[UIImage alloc];
buttonicon1=[UIImage imageNamed:@"Generalticket.png"];

how can set background of ticketButtonObj with buttonicon1 .. in left alignment ?

pls help me... thanks and regards by raju.

+3  A: 
UIButton *ticketButtonObj = [[UIButton alloc] initWithFrame:CGRectMake(140.0f 100.0f, 390.0f, 40.0f)];
UIImage* buttonicon1 = [UIImage imageNamed:@"Generalticket.png"];
[ticketButtonObj setImage:image forState:UIControlStateNormal];
ticketButtonObj.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;

or, if you want to set the background image:

[ticketButtonObj setBackgroundImage:image forState:UIControlStateNormal];

But you cannot set the alignment for the background.

Nikolai Ruhe