Reputation: 3469
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.
Upvotes: 0
Views: 1538
Reputation: 81878
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.
Upvotes: 3