问题描述
- ios模拟器屏幕只能显示左上角部分,求大神解决
-
刚刚开始学习ios,用ios编程第四版在学习,但是按照书上的代码运行后的矩形只能显示一部分,还请大神帮分析
@implementation AppDelegate- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
CGRect firstFrame = self.window.bounds; 这里是设置第一图层占满整个根图层,但是显示只显示4分之1矩形
MMXHypnosisView *firstView=[[MMXHypnosisView alloc]initWithFrame:firstFrame]; firstView.backgroundColor= [UIColor redColor]; [self.window addSubview:firstView]; // Override point for customization after application launch. self.window.backgroundColor = [UIColor whiteColor]; self.window.rootViewController = [[UIViewController alloc]init]; [self.window makeKeyAndVisible]; return YES;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
解决方案
拿到屏幕长度 宽度 然后再计算设置 这个需要动态计算得到你希望显示的位置 大小
时间: 2024-08-04 04:21:04