我必须像这样创建椭圆形的足球场
但我不知道哪个类/对象可以在 iPhone 中执行此操作?当用户触摸这个时,他/她得到了足球的位置。我做了很多谷歌搜索,但没有成功,请帮忙!! 我在 UIButton 中尝试这段代码
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.backgroundColor=[UIColor greenColor];
[button addTarget:self action:@selector(TappeMe) forControlEvents:UIControlEventTouchUpInside];
[button setTitle:@"" forState:UIControlStateNormal];
button.frame = CGRectMake(15.0, 10.0, 300.0, 400.0);
button.clipsToBounds = YES;
button.layer.cornerRadius = 130;
button.layer.borderColor=[UIColor redColor].CGColor;
button.layer.borderWidth=3.0f;
[self.view addSubview:button];
我得到了这个输出
提前致谢
最佳答案
只需使用 UIImageView 并将 UITapGestureRecognizer 添加到 ImageView 。参见示例 this UIGestureRecognizer tutorial .
关于iphone - 如何在 iPhone 中创建椭圆形足球场,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10345657/