ios基本控件操作

3 篇文章 0 订阅

随手记一下,省得以后老需要百度,想到哪里记到哪里吧.

视图切换

//直接返回根视图
[[self navigationController] popToRootViewControllerAnimated:YES];
//返回上级页面
[self.navigationController popViewControllerAnimated:YES];
//切换根视图
self.navigationController.tabBarController.hidesBottomBarWhenPushed=NO;
self.navigationController.tabBarController.selectedIndex=1;
//根据数量返回页面
 if (self.navigationController.viewControllers.count >=2) {
      UIViewController *listViewController =self.navigationController.viewControllers[1];
      [self.navigationController popToViewController:listViewController animated:YES];
}

UIButton

//设置按钮圆角
self.but.layer.cornerRadius = 15;
//设置边框
[self.but.layer setBorderWidth:1.0];
self.but.layer.borderColor=[UIColor blackColor].CGColor;
//点击事件
[self.but addTarget:self action:@selector(login) forControlEvents:UIControlEventTouchUpInside];

UIView

//绑定事件
    UITapGestureRecognizer* bankcardmethod = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(bankcardsgo)];
    [self.bankcardview addGestureRecognizer:bankcardmethod];
    self.bankcardview.userInteractionEnabled = YES;

UITextField

//键盘为数字
self.pass.keyboardType = UIKeyboardTypeNumberPad;
//输入文字右侧对齐
self.pass.textAlignment = NSTextAlignmentRight;
//输入框只读
self.pass.enabled=NO;
//修改TextField中的placeholder字体大小和颜色
 NSString *passText = @"请输入验证码";
    NSMutableAttributedString *passplaceholder = [[NSMutableAttributedString alloc] initWithString:passText];
     [passplaceholder addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"#808080"] range:NSMakeRange(0, passText.length)];
     [passplaceholder addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:16] range:NSMakeRange(0, passText.length)];self.pass.attributedPlaceholder = passplaceholder;

UITableView

//设置头视图
self.tableView.tableHeaderView = self.addstoreview;
//设置脚视图
self.tableView.tableFooterView = self.addstoreview;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值