UI2_IOS座標系

來源:互聯網
上載者:User

標籤:

////  AppDelegate.m//  UI2_IOS座標系////  Created by zhangxueming on 15/6/29.//  Copyright (c) 2015年 zhangxueming. All rights reserved.//#import "AppDelegate.h"@interface AppDelegate ()@end@implementation AppDelegate- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    // Override point for customization after application launch.            //window的預設顏色是透明色    self.window.backgroundColor = [UIColor whiteColor];    //NSLog(@"window = %@", self.window);    NSLog(@"x = %.2f y=%.2f w = %.2f h = %.2f",self.window.frame.origin.x, self.window.frame.origin.y, self.window.frame.size.width, self.window.frame.size.height);    //ios座標系    //frame座標: 相對於父視圖的座標    //bounds座標:ios座標(起始點從(0,0)開始)        //狀態列的高度是20        CGRect frame = [[UIScreen mainScreen] bounds];    NSLog(@"x = %.2f y = %.2f w= %.2f h = %.2f", frame.origin.x, frame.origin.y, frame.size.width, frame.size.height);        UIWindow *window1 = [[UIWindow alloc] initWithFrame:CGRectMake(10, 50, self.window.frame.size.width-20, self.window.frame.size.height-100)];    window1.backgroundColor = [UIColor cyanColor];        [self.window addSubview:window1];        //使window1在最上層顯示    [window1 makeKeyAndVisible];        //通常一個應用程式有一個Window(視窗)    //相當於一個容器    UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(20, 100, self.window.frame.size.width-40, 50)];    view1.backgroundColor = [UIColor redColor];        [self.window addSubview:view1];        //view1的retainCount加1    //NSLog(@"retainCount = %li", view1.retainCount);        self.window.rootViewController = nil;    return YES;}

 

UI2_IOS座標系

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.