supersr--addSubview和 insertSubView 区别

A addSubview B  是将B直接覆盖在A的最上层  例子: [self.view addSubview:scrollView];

A insertSubView B AtIndex:2 是将B插入到A的子视图index为2的位置(最底下是0)

A insertSubView B aboveSubview:C  是将B插入A并且在A已有的子视图C的上面

 
A insertSubView B belowSubview:C  是将B插入A并且在A已有的子视图C的下面 
例子: [self.viewinsertSubview:scrollView belowSubview: control];

转载于:https://www.cnblogs.com/supersr/p/4842504.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Objective-C 纯代码实现签到界面的步骤如下: 1. 创建一个 UIViewController。 ``` #import <UIKit/UIKit.h> @interface SignInViewController : UIViewController @end ``` 2. 在 UIViewController 中添加需要的 UI 元素。 ``` @interface SignInViewController () @property (nonatomic, strong) UILabel *titleLabel; @property (nonatomic, strong) UILabel *descriptionLabel; @property (nonatomic, strong) UILabel *dateLabel; @property (nonatomic, strong) UIButton *signInButton; @end @implementation SignInViewController - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor whiteColor]; self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 100, self.view.frame.size.width, 30)]; self.titleLabel.textAlignment = NSTextAlignmentCenter; self.titleLabel.text = @"签到"; [self.view addSubview:self.titleLabel]; self.descriptionLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 150, self.view.frame.size.width, 30)]; self.descriptionLabel.textAlignment = NSTextAlignmentCenter; self.descriptionLabel.text = @"签到可以获得积分哦"; [self.view addSubview:self.descriptionLabel]; self.dateLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 200, self.view.frame.size.width, 30)]; self.dateLabel.textAlignment = NSTextAlignmentCenter; self.dateLabel.text = [self getCurrentDate]; [self.view addSubview:self.dateLabel]; self.signInButton = [[UIButton alloc] initWithFrame:CGRectMake((self.view.frame.size.width - 100) / 2, 250, 100, 50)]; [self.signInButton setTitle:@"签到" forState:UIControlStateNormal]; [self.signInButton setTitleColor:[UIColor blueColor] forState:UIControlStateNormal]; [self.signInButton addTarget:self action:@selector(signInButtonAction) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:self.signInButton]; } - (NSString *)getCurrentDate { NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setDateFormat:@"yyyy-MM-dd"]; NSString *currentDate = [formatter stringFromDate:[NSDate date]]; return currentDate; } - (void)signInButtonAction { // 处理签到逻辑 } @end ``` 3. 在需要的地方创建 SignInViewController 并展示。 ``` SignInViewController *signInViewController = [[SignInViewController alloc] init]; [self.navigationController pushViewController:signInViewController animated:YES]; ``` 以上就是 Objective-C 纯代码实现签到界面的步骤。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值