0
我正在試驗在屏幕上顯示UIView
的不同方式......我目前有此代碼,並認爲它應該可以將綠色UIView
添加到應用程序窗口,但是,它沒有:嘗試通過類方法實例化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];
}
是什麼調用showLoginView? – futureelite7