gpt4 book ai didi

iphone - UIButton 背景 VS UIButton imageview.view

转载 作者:可可西里 更新时间:2023-11-01 05:10:22 24 4
gpt4 key购买 nike

UIButton背景和UIButton imageview.view有什么区别我尝试了 myButton.imageView.image=[UIImage imageNamed:@"image.png"]; 然后没有任何反应,但是当我使用 [myButton setBackgroundImage:[UIImage imageNamed:@"image. png"] forState:UIControlStateNormal];按钮的背景发生变化。

谢谢!

最佳答案

myButton.imageView.image 是只读属性,因此不能像这样更改。而 setBackgroundImage 是一种正确设置背景的方法。

//编辑

UIButton 的 setImage 方法需要两个参数,

setImage:(UIImage *) forState:(UIControlState)

因此使用上述方法可以正常工作,而其他方法则不行。

关于iphone - UIButton 背景 VS UIButton imageview.view,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9112315/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com