object-UI之基本控件

Buttion控件

//添加一个按钮
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
    //设置大小
    btn.bounds = CGRectMake(0, 0, 60, 40);
    //设置中心点
    btn.center = CGPointMake(screen / 2, 40);
    //设置显示的文字
    [btn setTitle:@"下一页" forState:UIControlStateNormal];
    //设置btn的背景颜色
    btn.backgroundColor = [UIColor blueColor];
    //设置圆角
    btn.layer.cornerRadius = 5;
    //设置阴影
    btn.layer.shadowColor = [UIColor grayColor].CGColor;
    //设置偏移量
    btn.layer.shadowOffset = CGSizeMake(5, 10);
    //设置透明度
    btn.layer.shadowOpacity = 1;
    //添加事件
    [btn addTarget:self action:@selector(btnClicked) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];
    //设置btn的位置和大小(整个屏幕那么大)
        _btn.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);
        //设置btn的字体位置
        _btn.titleLabel.textAlignment = NSTextAlignmentCenter;
        //设置btn字体颜色
        _btn.titleLabel.textColor = [UIColor redColor];
UITextField文本控件

    //添加一个文本控件
    UITextField *textField = [[UITextField alloc]init];
    //设置文本控件的背景颜色
    textField.textColor = [UIColor whiteColor];
    //设置文本控件光标颜色
    textField.tintColor = [UIColor whiteColor];
    //设置文本控件文本位置
    textField.textAlignment = NSTextAlignmentRight;
    //设置文本控件文本内容
    textField.text = @"0";
    //设置文本控件位置大小
    textField.frame = CGRectMake(2, 150, screen-10, 20);
    //设置字体和粗细
    textField.font = [UIFont systemFontOfSize:25 weight:0.5];
    //设置文本颜色
    textField.textColor = [UIColor blueColor];
    _text = textField;
    [self.view addSubview:textField];

UILabel文本标签控件

  UILabel *titleLabel = [[UILabel alloc]init];
    //获取屏幕的尺寸
    CGFloat screen = [UIScreen mainScreen].bounds.size.width;
    //设置尺寸
    titleLabel.bounds = CGRectMake(0, 0, screen, 44);
    //设置中心点
    titleLabel.center = CGPointMake(screen/2, 42);
    //设置背景色
    titleLabel.backgroundColor = [UIColor grayColor];
    //设置内容
    titleLabel.text = @"标题栏";
    //文本位置
    titleLabel.textAlignment = NSTextAlignmentCenter;
    //字体大小和粗细
    titleLabel.font = [UIFont systemFontOfSize:24 weight:0.2];

新手总结。。学习得还是比较少。另外还有对于视图一个弹出弹入的两个动画方法。

//窗口弹入来
    [self presentViewController:myView animated:YES completion:^{
        NSLog(@"ss");//这里是动画结束后要做的事情
    }];
//当前窗口弹出去
    [self dismissViewControllerAnimated:YES completion:nil];//动画完成后事件也可以为空

暂时说到这里吧。。上课继续。。


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值