中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

IOS 代碼創(chuàng)建控件,并有處理事件

2018-07-20    來源:open-open

容器云強勢上線!快速搭建集群,上萬Linux鏡像隨意使用
    @interface AppDelegate()  
      
    @property UILabel* show;  
    @end  
      
    @implementation AppDelegate  
      
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions  
    {  
        self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];  
        // Override point for customization after application launch.  
        self.window.backgroundColor = [UIColor whiteColor];  
          
        //創(chuàng)建一個UIViewController 對象  
        UIViewController* controller = [[UIViewController alloc] init];  
        //讓該程序的窗口加載并顯示 viewController 視圖控制器關(guān)聯(lián)的用戶界面  
        self.window.rootViewController = controller;  
        //創(chuàng)建一個UIView 對象  
        UIView* rootView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];  
        //設(shè)置 controller 顯示 rootView 控件  
        controller.view = rootView;  
        //創(chuàng)建一個圓角按鈕  
        UIButton* button = [UIButton buttonWithType:UIButtonTypeRoundedRect];  
        //設(shè)置按鈕的大小  
        button.frame = CGRectMake(120, 100, 80, 40);  
        //為按鈕設(shè)置文本  
        [button setTitle:@"確定" forState:UIControlStateNormal];  
        //將按鈕添加到 rootView 控件中  
        [rootView addSubview:button];  
        //創(chuàng)建一個 UILabel 對象  
        self.show = [[UILabel alloc] initWithFrame:CGRectMake(60, 40, 180, 30)];  
    //    UILabel* show = [[UILabel alloc] initWithFrame:CGRectMake(60, 40, 180, 30)];  
        //將UILabel 添加到 rootView 控件中  
        [rootView addSubview: self.show];  
        //設(shè)置 UILabel 默認顯示的文本  
        self.show.text = @"初始文本";  
        self.show.backgroundColor = [UIColor grayColor];  
        //為圓角按鈕的觸碰事件綁定事件處理方法  
        [button addTarget:self action:@selector(clickHandler:) forControlEvents:UIControlEventTouchUpInside];  
          
        //將該 UIWindow 對象設(shè)為主窗口并顯示出來  
        [self.window makeKeyAndVisible];  
        return YES;  
    }  

    - (void)clickHandler:(id)sender {  
        self.show.text = @"開始學習 IOS 吧!";  
    }  

標簽:

版權(quán)申明:本站文章部分自網(wǎng)絡(luò),如有侵權(quán),請聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請與原作者聯(lián)系。

上一篇:php生成折線圖代碼

下一篇:NSData使用與分析