我想要一个图片和文字“查看详情” 在我的按钮(红色按钮)中以编程方式...... 图像在按钮的左侧,文本在右侧..
UIImage *img = [UIImage imageNamed:@"image.png"];
[aButton setImage:img forState:UIControlStateNormal];
aButton.backgroundColor=[UIColor redColor];
//[img release]; i am not sure i release it or not
//[testBtn setTitleEdgeInsets:UIEdgeInsetsMake(70.0, -150.0, 5.0, 5.0)];
// what the above lines line work?
[aButton setTitle:@"View Details" forState:UIControlStateNormal];
我看到按钮但没有,红色按钮...只有红色角...
最佳答案
你制作了带有红色和文本的按钮图像..并在其上设置图像...
这是在按钮上设置图像的代码..
[but1 setImage:[UIImage imageNamed:@"LeftBack.png"] forState:UIControlStateNormal]
;//在按钮上设置图像。
关于iphone - 以编程方式在按钮上添加图像和文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7847794/