我想以编程方式添加myView
到父视图。但它不会出现在屏幕上。代码有什么问题?
@interface ViewController ()
@property (nonatomic,weak) UIView *myView;
@end
@implementation ViewController
@synthesize myView = _myView;
- (void)viewDidLoad
{
[super viewDidLoad];
CGRect viewRect = CGRectMake(10, 10, 100, 100);
self.myView = [[UIView alloc] initWithFrame:viewRect];
self.myView.backgroundColor = [UIColor redColor];
[self.view addSubview:self.myView];
}