iphone – 自定义UIButton图像iOS

iphone – 自定义UIButton图像iOS,第1张

概述是否可以拥有一个自定义UIButton,其图像只覆盖其中的一半? 我想它会是这样的: UIButton *someButton = [UIButton buttonWithType:UIButtonTypeCustom];[someButton setBackgroundImage:[UIImage imageNamed:@"buttonPicture"]];/* Then there mu 是否可以拥有一个自定义UIbutton,其图像只覆盖其中的一半?
我想它会是这样的:

UIbutton *somebutton = [UIbutton buttonWithType:UIbuttonTypeCustom];[somebutton setBackgroundImage:[UIImage imagenamed:@"buttonPicture"]];/* Then there must be some property I can set that prevents the button from stretching the image?? */...

我希望有一个50x100px按钮,上半部分只有50x50px图像,下半部分透明.

我知道如何创建自定义按钮和一切.我只是想知道什么属性控制backgroundImage的拉伸.

谢谢!

解决方法 使用

[somebutton setimage:[UIImage imagenamed:@"buttonPicture"] forState: UIControlStatenormal]; somebutton.imageEdgeInsets = UIEdgeInsetsMake(-50,0);
总结

以上是内存溢出为你收集整理的iphone – 自定义UIButton图像iOS全部内容,希望文章能够帮你解决iphone – 自定义UIButton图像iOS所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1080925.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-27
下一篇2022-05-27

发表评论

登录后才能评论

评论列表(0条)

    保存