Reputation: 217
Guys can you please help me to convert this swift code to objective-c:
import UIKit
@IBDesignable
class PushTheButton: UIButton {
@IBInspectable var fillColor: UIColor = UIColor.greenColor()
@IBInspectable var isAddButton: Bool = true
override func drawRect(rect: CGRect) {
let path = UIBezierPath(ovalInRect: rect)
fillColor.setFill()
path.fill()
}
}
and where should I put the code? is it in the header or implementation? I would appreciate it if you could help me?
Upvotes: 0
Views: 142
Reputation: 211
There will be two files on obj-c: header and implementation:
"PushTheButton.h"
#import <UIKit/UIKit.h>
IB_DESIGNABLE
@interface PushTheButton : UIButton
@property (nonatomic) IBInspectable UIColor *fillColor;
@property (nonatomic) IBInspectable BOOL isAddButton;
@end
"PushTheButton.m"
#import "FSView1.h"
@implementation PushTheButton
- (void)awakeFromNib {
[super awakeFromNib];
self.fillColor = [UIColor greenColor];
self.isAddButton = YES;
}
- (void)drawRect:(CGRect)rect {
UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:rect];
[self.fillColor setFill];
[path fill];
}
@end
Upvotes: 2