【发布时间】:2016-08-12 09:28:53
【问题描述】:
我需要在 UIButton 外面画一个像边框一样的圆圈。以下是附加图像和代码。我还需要在按钮下方显示文本。以下代码将在其下方添加图像和文本。但是我怎么有层。
UIButton *imageButton = [UIButton buttonWithType:UIButtonTypeCustom];
[imageButton setBackgroundImage:image forState:UIControlStateNormal];
imageButton.translatesAutoresizingMaskIntoConstraints = NO;
imageButton.backgroundColor = [UIColor clearColor];
[imageButton setTitle:title forState:UIControlStateNormal];
imageButton.titleLabel.textAlignment = NSTextAlignmentCenter;
imageButton.titleLabel.font = [UIFont fontWithName:@"OpenSans" size:fon];
[imageButton setTitleEdgeInsets:UIEdgeInsetsMake(95, 0.0f, 0.0f, 0.0f)];
[imageButton setTitleColor:[UIColor iconTextColor] forState:UIControlStateNormal];
[imageButton addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
【问题讨论】:
-
this 教程的一部分可能会有所帮助。
-
查看 CAShapeLayer 和
+[UIBezierPath bezierPathWithArcCenter: radius: startAngle: endAngle: clockwise: ]
标签: ios objective-c iphone uibutton