刚学ios,在做ios编程里面的小练习--新建了一个singleview项目,想在一个UIwindow里画个红色的矩形并铺满整个窗口,AppDelegate.h里代码如下:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
self.window=[[UIWindow alloc]initWithFrame:
[[UIScreen mainScreen]bounds]];
//CGRect firstFrame=CGRectMake(160, 240, 100, 150);
CGRect firstFrame=self.window.bounds;
BNRHypnosisiView *firstView=[[BNRHypnosisiView alloc]initWithFrame:firstFrame];
firstView.backgroundColor=[UIColor redColor];
[self.window addSubview:firstView];
self.window.backgroundColor=[UIColor whiteColor];
[self.window makeKeyAndVisible]; return YES;
}
但出来的效果却只占屏幕左上角的1/4。。是哪里出了问题呢?真心求教~~
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
self.window=[[UIWindow alloc]initWithFrame:
[[UIScreen mainScreen]bounds]];
//CGRect firstFrame=CGRectMake(160, 240, 100, 150);
CGRect firstFrame=self.window.bounds;
BNRHypnosisiView *firstView=[[BNRHypnosisiView alloc]initWithFrame:firstFrame];
firstView.backgroundColor=[UIColor redColor];
[self.window addSubview:firstView];
self.window.backgroundColor=[UIColor whiteColor];
[self.window makeKeyAndVisible]; return YES;
}
但出来的效果却只占屏幕左上角的1/4。。是哪里出了问题呢?真心求教~~
[UIScreen mainScreen].bounds.size.width