0
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的问候。

4

1 回答 1

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];

但是您不能设置背景的对齐方式。

于 2009-06-08T06:09:06.023 回答