gpt4 book ai didi

ios - ImageView 和 UIButton

转载 作者:可可西里 更新时间:2023-11-01 06:18:20 25 4
gpt4 key购买 nike

我想创建一个带有自定义图像(背景图像)的按钮,我已经做到了。如何将 ImageView 分配给可能的按钮?

感谢您的回答

UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button addTarget:self
action:@selector(goToGeoloc)
forControlEvents:UIControlEventTouchDown];
[button setTitle:@"Show View" forState:UIControlStateNormal];
button.frame = CGRectMake(245.0, 8.0, 45.0, 45.0);
UIImage *image = [UIImage imageNamed:@"ico_plan.png"];
UIImageView *imageView = [[UIImageView alloc]initWithImage:image];

最佳答案

你想要的是:

[button setBackgroundImage:image forState:UIControlStateNormal];

[button setImage:image forState:UIControlStateNormal];

关于ios - ImageView 和 UIButton,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5880478/

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