UIButton *ticketButtonObj=
[[UIButton alloc]initWithFrame:CGRectMake(140.0f 100.0f, 390.0f, 40.0f)];
UIImage *buttonicon1=[UIImage alloc];
buttonicon1=[UIImage imageNamed:@"Generalticket.png"];
如何在左对齐中用buttonicon1 ..设置ticketButtonObj的背景?
请帮助我... raju的感谢和问候。
答案 0 :(得分:3)
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;
或者,如果要设置背景图像:
[ticketButtonObj setBackgroundImage:image forState:UIControlStateNormal];
但是你无法设置背景的对齐方式。