我正在尝试UIView
在屏幕上显示 a 的不同方式......我目前有这段代码,并认为它应该可以将绿色添加UIView
到应用程序的窗口中,但是,它没有:
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
NSLog(@"init");
self.backgroundColor = [UIColor greenColor];
self.alpha = 1;
}
return self;
}
+ (SMLoginView *)sharedView{
static dispatch_once_t onceToken;
static SMLoginView *sharedView;
dispatch_once(&onceToken, ^{
sharedView = [[self alloc]initWithFrame:[UIScreen mainScreen].bounds];
});
return sharedView;
}
+ (void)showLoginView{
[[self sharedView]show];
}
- (void)show{
NSLog(@"Show");
[[[[UIApplication sharedApplication] delegate] window] addSubview:self];
}