我有一个像这样的 UIImageView:
UIImage *image = [UIImage imageNamed:@"test.png"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
imageView.frame = CGRectMake(0, 0, 30, 30);
imageView.layer.cornerRadius = 5.0;
imageView.layer.masksToBounds = YES;
imageView.layer.borderColor = [UIColor lightGrayColor].CGColor;
imageView.layer.borderWidth = 0.1;
[self.view addSubview:imageView];
几个问题/问题:
- 如何使它成为可点击的按钮?
我想链接到“设置”(在我的应用程序中),但我是否必须像许多应用程序使用的设置图标一样创建图像轮,或者它是 iOS 7 中的标准图标? 这是我正在谈论的图标:
为什么我的边框不显示?
最佳答案
1) 如果你想要一个按钮,你应该使用 UIButton并使用 [UIButton setImage: forState:]
2) 或者,您可以添加 UITapGestureRecognizer到你当前的 UIImageView
关于ios - 如何使 UIImageView 成为按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24300053/