0

I'm creating rounded button for my app with paintcode. The steps I follows are - creating new class derived for UIButton, paste the code generated by paintcode inside (void)drawRect:(CGRect)rect and set button to use my custom class. But I'm doing something wrong because the button doesn't have any shape at all, it's just a label. This is the code I use -

//// Color Declarations
UIColor* strokeColor = [UIColor colorWithRed: 0 green: 0 blue: 0 alpha: 1];
UIColor* fillColor2 = [UIColor colorWithRed: 0.886 green: 0 blue: 0 alpha: 1];

//// Rounded Rectangle Drawing
UIBezierPath* roundedRectanglePath = [UIBezierPath bezierPathWithRoundedRect: CGRectMake(44.5, 45.5, 48, 20) cornerRadius: 4];
[fillColor2 setFill];
[roundedRectanglePath fill];
[strokeColor setStroke];
roundedRectanglePath.lineWidth = 1;
[roundedRectanglePath stroke];
Jay
  • 6,572
  • 3
  • 37
  • 65
user3273345
  • 127
  • 2
  • 9

1 Answers1

0
//// Color Declarations
UIColor* strokeColor = [UIColor colorWithRed: 0 green: 0 blue: 0 alpha: 1];
UIColor* fillColor2 = [UIColor colorWithRed: 0.886 green: 0 blue: 0 alpha: 1];

//// Frames: Set frame to "rect" to have the custom button fit in the UIButton frame
CGRect frame = CGRectMake(45, 45, 48, 20);


//// CustomButton
{
    //// Rounded Rectangle Drawing
    UIBezierPath* roundedRectanglePath = [UIBezierPath bezierPathWithRoundedRect: CGRectMake(CGRectGetMinX(frame) + 1.5, CGRectGetMinY(frame) + 0.5, CGRectGetWidth(frame) - 3, CGRectGetHeight(frame) - 2) cornerRadius: 4];
    [fillColor2 setFill];
    [roundedRectanglePath fill];
    [strokeColor setStroke];
    roundedRectanglePath.lineWidth = 1;
    [roundedRectanglePath stroke];
}
Francis
  • 31
  • 3