iphone - 如何在 iPhone 中创建椭圆形足球场

标签 iphone objective-c ios xcode uibutton

我必须像这样创建椭圆形的足球场 enter image description here

但我不知道哪个类/对象可以在 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];

我得到了这个输出 enter image description here

提前致谢

最佳答案

只需使用 UIImageView 并将 UITapGestureRecognizer 添加到 ImageView 。参见示例 this UIGestureRecognizer tutorial .

关于iphone - 如何在 iPhone 中创建椭圆形足球场,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10345657/

相关文章:

c++ - 关于 OpenGLES 中的纹理切换

ios - 保留 View Controller 的计数

ios - 在安装 iOS 应用程序时提醒用户所需的 iOS 版本

ios - 如何获取位置坐标以在另一个类中更新?

ios - AVPlayer 有时无法播放视频

ios - 使用 coredata 获取父文件夹内的子文件和文件夹的谓词

iphone - 如何使导航栏像 Pulse 中的那样?

objective-c - iOS 上的电话号码格式

iphone - 检查字典中是否存在标签

ios - 无法使以编程方式创建的 UITextField 可编辑 (iOS)