prepareForInterfaceBuilder不会更新我的故事板

时间:2015-01-30 08:10:27

标签: ios objective-c xcode xcode6

我创建了一个简单的日历视图,并希望在我的故事板上看到它现场呈现,但我设法只显示-drawRect:中的代码。 在模拟器上运行我得到这个图像,代表正确的最终结果,但在故事板中,我得到了这个 enter image description here
在故事板上我得到了这个enter image description here
CalendarDayView是另一个视图的子类,其目的是加载具有特定名称的笔尖并将其添加为子视图。 CalendarDayView被标记为IB_DESIGNABLE 它作为子视图直接添加到故事板上。
要在CalendarDayView方法-prepareForInterfaceBuilder中显示标签,我还会写一些占位符文字。

- (void) prepareForInterfaceBuilder {
    [super prepareForInterfaceBuilder];
    self.yearLabel.text = @"2015";
    self.monthLabel.text = @"FEBRUARY";
    self.dayLabel.text = @"28";
}


绘制rect显示正常

- (void) drawRect:(CGRect)rect {
    self.backgroundColor = [UIColor clearColor];
    UIBezierPath * path = [UIBezierPath bezierPathWithRoundedRect:self.bounds cornerRadius:20];
    [APP_CALENDAR_VIEW_COLOR setFill];
    [path fill];
}


如何在编辑故事板时显示标签?即使我显示预览也没有显示。

0 个答案:

没有答案