这是AppDelegate里的代码,还定义了一个UIView类BNRHypnosister,里面只有一个实参CGRect- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
    UIViewController *emptyView = [[UIViewController alloc] initWithNibName: nil bundle:nil ];
    self. window .rootViewController = emptyView;
   CGRect firstFrame = CGRectMake(100.0f, 10.0f, 200, 300)
    BNRHypnosister *firstView = [[BNRHypnosister alloc] initWithFrame: firstFrame];
    firstView.backgroundColor = [UIColor redColor];
    [self.window addSubview: firstView];
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    
    return YES;
}然后无论我怎样修改坐标,长方形始终在屏幕左上角,我搞了一下午了,弄不出来,求帮忙,aotolayout也关了,没用

解决方案 »

  1.   

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        self.window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
        UIViewController *emptyView = [[UIViewController alloc] initWithNibName: nil bundle:nil ];
        self. window .rootViewController = emptyView;
        CGRect firstFrame = CGRectMake(200.0f, 100.0f, 200, 300);
        UIView *firstView = [[UIView alloc] initWithFrame: firstFrame];
        firstView.backgroundColor = [UIColor redColor];
        [self.window addSubview: firstView];
        self.window.backgroundColor = [UIColor whiteColor];
        [self.window makeKeyAndVisible];
        
        return YES;
    }
    没有问题啊