Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Creating a custom button may be helpful.</p> <p>in the .h file;</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; @interface CircleLineButton : UIButton - (void)drawCircleButton:(UIColor *)color; @end </code></pre> <p>in the .m file;</p> <pre><code> #import "CircleLineButton.h" @interface CircleLineButton () @property (nonatomic, strong) CAShapeLayer *circleLayer; @property (nonatomic, strong) UIColor *color; @end @implementation CircleLineButton - (void)drawCircleButton:(UIColor *)color { self.color = color; [self setTitleColor:color forState:UIControlStateNormal]; self.circleLayer = [CAShapeLayer layer]; [self.circleLayer setBounds:CGRectMake(0.0f, 0.0f, [self bounds].size.width, [self bounds].size.height)]; [self.circleLayer setPosition:CGPointMake(CGRectGetMidX([self bounds]),CGRectGetMidY([self bounds]))]; UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(0, 0, CGRectGetWidth(self.frame), CGRectGetHeight(self.frame))]; [self.circleLayer setPath:[path CGPath]]; [self.circleLayer setStrokeColor:[color CGColor]]; [self.circleLayer setLineWidth:2.0f]; [self.circleLayer setFillColor:[[UIColor clearColor] CGColor]]; [[self layer] addSublayer:self.circleLayer]; } - (void)setHighlighted:(BOOL)highlighted { if (highlighted) { self.titleLabel.textColor = [UIColor whiteColor]; [self.circleLayer setFillColor:self.color.CGColor]; } else { [self.circleLayer setFillColor:[UIColor clearColor].CGColor]; self.titleLabel.textColor = self.color; } } @end </code></pre> <p>And in the view controller, call <code>[self.myCircleButton drawCircleButton:[UIColor myColor]]</code></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload