布局是这样的:
BackgroundColor.h
#import <UIKit/UIKit.h>
@interface BackgroundColor : UIView
@end
BackgroundColor.m
#import "BackgroundColor"
@implementation BackgroundColor___Fuschia
- (void)drawRect:(CGRect)rect
{
...
}
@end
ViewControllerNav.h
#import <UIKit/UIKit.h>
@interface ViewControllerNav : UIViewController
@end
ViewControllerNav.m
@interface ViewControllerNav ()
@end
@implementation ViewControllerNav
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
我假设我必须导入BackgroundColor并初始化方法或?
(PS:我的drawRect方法使用CGRect frame = rect;所以我需要通过i asume的视图大小?)
任何帮助都是apriciated
答案 0 :(得分:1)
要回答原始问题,请不要直接调用drawRect:你打电话
[self.view setNeedsDisplay];
并且系统负责在适当的时间调用drawRect。