gpt4 book ai didi

ios - 添加图像以查看

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

如何向 UIView 添加图像?到目前为止,这是我尝试过的:

UIView *imageHolder = [[UIView alloc] initWithFrame:CGRectMake(40, 200, 280, 192)];
UIImage *image = [UIImage imageNamed:@"bloodymoon.jpg"];
[imageHolder addSubview:image]; // Error: Incompatible pointer types
[self.mainView addSubview:imageHolder];

最佳答案

试试 UIImageView:

UIImageView *imageHolder = [[UIImageView alloc] initWithFrame:CGRectMake(40, 200, 280, 192)];
UIImage *image = [UIImage imageNamed:@"bloodymoon.jpg"];
imageHolder.image = image;
// optional:
// [imageHolder sizeToFit];
[self.mainView addSubview:imageHolder];

关于ios - 添加图像以查看,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9317911/

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