iphone - 如何在 iphone 中以编程方式实现带有背景图像的按钮

标签 iphone ios uibutton

我正在 iPhone 中以编程方式使用按钮开发图像。现在我想为下一个和上一个按钮添加按钮背景图像。我想以编程方式为这些按钮添加图像。

如何在iphone中添加按钮图片。

最佳答案

//像这样添加按钮

UIImage *redButtonImage = [UIImage imageNamed:@"ExitButton.png"];

        UIButton *redButton = [UIButton buttonWithType:UIButtonTypeCustom];
        redButton.frame = CGRectMake(280.0, 10.0, 29.0, 29.0);
        [redButton setBackgroundImage:redButtonImage forState:UIControlStateNormal];

        [view addSubview:redButton];

关于iphone - 如何在 iphone 中以编程方式实现带有背景图像的按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5012305/

相关文章:

iphone - 如何在 iPhone 的 UITextView 中嵌入链接

iphone - Xcode 慢得令人难以忍受(而且是谎言)。为什么?

ios - 在 SwiftUI 的 MapKit 中渲染实时路径

ios - 不可用时隐藏 iAd

ios - 在 Swift 中设置 UIButton Image - 当前解包为 nil

ios - UIPageViewController 和 UIButton 混合使用

iphone - 如何从我的应用程序启动应用商店

iphone - 查看 socket 未设置? (Xcode)

ios - swift/iOS : Collapsing a section in a UITableView

ios - 获取 UIBarButtonItem 的坐标或 CGPoint