通过代码随机化 UIImageViews
我的视图中有 8 张图像。视图中左侧有 4 个,右侧有 4 个。我每次都需要将图像从左侧匹配到右侧。我通过在界面生成器中创建 8 个图像视图并将其连接到创建的插座来静态地完成此操作。现在我必须动态随机化图像视图,这样匹配就不会变得明显。就像第一个左最上面的图像视图一样,匹配项将始终位于右侧图像视图的最底部。我尝试以 2 种格式创建图像视图
UIImageView *image1 = [[UIImageView alloc] initWithFrame:CGRect(111, 135,140,130)]; image1.image = [UIImage imageNamed:@"iMac.png"
也
UIImageView *image1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"iMac.png"]]; image1.frame = CGRect(111,135,140,130);
图像根本不显示在屏幕上。如果我的代码有错误,请纠正我
I have 8 images on my View. 4 on left n 4 on right side on the view. i need to match images every time from ones on left to ones on right. I have done this statically by creating 8 image views in the interface builder and connecting it to the outlets created. Now i have to dynamically randomize the image views so tat the match doesn't become obvious. like for the 1st left topmost imageview the match will always be at the bottom most in the right side image view. i tried creating image views in 2 formats
UIImageView *image1 = [[UIImageView alloc] initWithFrame:CGRect(111, 135,140,130)];
image1.image = [UIImage imageNamed:@"iMac.png"
also
UIImageView *image1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"iMac.png"]];
image1.frame = CGRect(111,135,140,130);
images are not displayed on the screen at all. Please correct me if i have gone wrong in the code
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需替换
为
Just Replace
with