我需要从a的左侧显示电子邮件地址UIButton,但它位于中心.
有没有办法将对齐设置为左侧UIButton?
这是我目前的代码:
UIButton* emailBtn = [[UIButton alloc] initWithFrame:CGRectMake(5,30,250,height+15)];
emailBtn.backgroundColor = [UIColor clearColor];
[emailBtn setTitle:obj2.customerEmail forState:UIControlStateNormal];
emailBtn.titleLabel.font = [UIFont systemFontOfSize:12.5];
[emailBtn setTitleColor:[[[UIColor alloc]initWithRed:0.121 green:0.472 blue:0.823 alpha:1]autorelease] forState:UIControlStateNormal];
[emailBtn addTarget:self action:@selector(emailAction:) forControlEvents:UIControlEventTouchUpInside];
[elementView addSubview:emailBtn];
[emailBtn release];
Run Code Online (Sandbox Code Playgroud) 如果可以避免,我不想使用子视图.我想要一个UIButton背景图片,文字和图像.现在,当我这样做时,图像位于文本的左侧.背景图像,文本和图像都具有不同的突出显示状态.
关于根据标题文本对齐按钮图像有很多线索,但我找不到任何关于将图像对齐到按钮右侧的信息.
这没有效果:
button.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 50);
Run Code Online (Sandbox Code Playgroud)
如何将图像右键对齐按钮?可以在故事板中完成吗?