【发布时间】:2015-11-14 21:08:33
【问题描述】:
我有一个自定义 UIView 和名为 DialPad 的 xib,我正在尝试在我的故事板中使用这个对象,但自定义 DialPad 没有被添加为带有按钮的子视图
我的自定义拨号盘:UIView
@implementation DialPad
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
self.backgroundColor = [UIColor clearColor];
}
return self;
}
我的视图控制器看起来像这样
#import <UIKit/UIKit.h>
#import "DialPad.h"
@interface ViewController : UIViewController
@property (weak, nonatomic) IBOutlet UIView *dial;
@end
#import "ViewController.h"
@interface ViewController ()
{
DialPad *d;
}
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
d = [[DialPad alloc] initWithFrame:self.dial.frame];
[self.dial addSubview:d];
}
@end
但是视图周围的边框看起来很奇怪
#import "DialPad.h"
#import <QuartzCore/QuartzCore.h>
@implementation DialPad
- (void)drawRect:(CGRect)rect
{
// Drawing code
self.layer.borderColor = [UIColor redColor].CGColor;
self.layer.borderWidth = 1;
}
@end
【问题讨论】:
标签: objective-c uiview uistoryboard xib