zoukankan      html  css  js  c++  java
  • ios-UI1

    //  AppDelegate.h
    //  01-HelloWorld的实现
    //
    /*
     新建工程的时候,Use Core Data:比如本地缓存,
     Include Unit test:增加单元测试
     Include UI test:UI的测试。
     
     AppDelegate.h:代理
     AppDelegate.m
     ViewController.h:控制器
     ViewController.m:
     Main.storyboard:主故事板
     Assets.xcassets:图片资源
     LaunchScreen.storyboard:启动屏幕,做广告的,
     Info.plist:应用的配置信息
     Supporting Files:外部拉入的东西
     程序从Supporting Files下面的main.m文件启动。找到AppDelegate.m代理,做事情的,找MAin Inteface。
     
     
     
     Bundle:唯一标示,
     Team:打包需要证书。
     Deployment Target:预编译的版本,一般选择7.0,8.0,
     MAin Inteface(工程--General):主交互界面,第一个启动的界面(storyboard)。
     View Controller:是用来管理View和VIew里面的内容的。  展示给用户的是View。一个控制器只能够管理一个页面,负责处理事件。
     
     也可以自定义一个storyboard作为程序的启动界面,并且新的storyboard要自己拖一个View Controller和View。并且加一个箭头(title--is init View Controller)就有可一个箭头。并且可以拖多个控制器。
     
     
     可以为View Controller自定义class,右键--new file--Cocoa Touch Class--要继承UIViewController,然后在面板上Class选择自定义的class(My2ViewController),这样就为View Controller绑定了自定义的My2ViewController。
     */
    
    #import <UIKit/UIKit.h>
    
    @interface AppDelegate : UIResponder <UIApplicationDelegate>
    
    @property (strong, nonatomic) UIWindow *window;
    
    
    @end
    //
    //  My2ViewController.h
    //  01-HelloWorld的实现
    //
    
    #import <UIKit/UIKit.h>
    
    @interface My2ViewController : UIViewController
    
    /*
    //只有声明为IBOutlet的属性才能跟storyboard的属性进行关联,放在.m文件的类扩展里面,放在.h文件里面是公有的,放在.m文件里面是私有的。
    @property(nonatomic, weak)IBOutlet UILabel *label;
    */
    @end
    //
    //  My2ViewController.m
    //  01-HelloWorld的实现
    //
    /*
        IBAction:从返回值的角度看,作用相当于void,
        IB:Interface Builder一个软件。
        只有返回值声明为IBAction的方法,才能根storyboard中的控件进行连线。
     */
    
    #import "My2ViewController.h"
    
    @interface My2ViewController () //类扩展,为类扩展属性和方法,类扩展也是匿名分类,放私有的属性和方法,
    
    //只有声明为IBOutlet的属性才能跟storyboard的属性进行关联,放在.m文件的类扩展里面,放在.h文件里面是公有的,放在.m文件里面是私有的。
    //判断对象在不在内存中是通过是否有强指针指向。 有一个强指针指向着View Control。View Control是不会死的,View Control有一个强指针指着View,View也不会死,View里面也有一个强指针指着label。所以这里是weak不影响,因为他本来就不会死。
    @property(nonatomic, weak)IBOutlet UILabel *label;
    
    @end
    
    @implementation My2ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        // Do any additional setup after loading the view.
    }
    
    - (void)didReceiveMemoryWarning {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }
    
    /*
    #pragma mark - Navigation
    
    // In a storyboard-based application, you will often want to do a little preparation before navigation
    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
        // Get the new view controller using [segue destinationViewController].
        // Pass the selected object to the new view controller.
    }
    */
    
    
    #pragma mark  -点击b1
    -(IBAction)click1{  //点击2个圈圈分屏通过连线和按钮建立关联,
        NSLog(@"111");
        self.label.textColor = [UIColor redColor];
        self.label.text = @"11";
    }
    
    -(IBAction)click2{
        NSLog(@"222");
        self.label.textColor = [UIColor  greenColor];
        self.label.text = @"22222222222222222222222222222222222222222222222222222222222222222";
        self.label.backgroundColor = [UIColor blueColor];
    }
    
    -(IBAction)click3{
        NSLog(@"333");
        // 改变文字的颜色
        self.label.textColor = [UIColor redColor];  //self是当前控制器
        // 改变文本的内容
        self.label.text = @"我是一段红色的文字";
        // 改变背景颜色
        self.label.backgroundColor = [UIColor greenColor];
        // 文字居中
        self.label.textAlignment = NSTextAlignmentCenter;
        // 改变文字的大小,默认是17,
        self.label.font = [UIFont systemFontOfSize:20.f];
    }
    @end
  • 相关阅读:
    spring注解方式AOP
    struts2 值栈的理解
    JAVA自定义注解
    JS学习随笔。
    使用Jsoup解析html网页
    Struts迭代器(iterator)遍历List常用的4种例子
    Maven 结合 Spring profile对不同的部署环境打包部署
    打印插件LODOP使用介绍
    Linux下查看CPU信息、机器型号等硬件信息
    验证码的生成和验证
  • 原文地址:https://www.cnblogs.com/yaowen/p/7445226.html
Copyright © 2011-2022 走看看