UIView添加针对安全区域的约束

时间:2019-10-24 08:41:36

标签: ios iphone constraints

我正在这样创建视图控制器:

  CGRect textBounds = ....;

  CGRect labelFrame = CGRectMake(, 0, textBounds.size.width, textBounds.size.height);
  UILabel *label = [[UILabel alloc] initWithFrame:labelFrame];
  label.attributedText = someText;
  label.numberOfLines = 0;

  CGRect viewFrame = CGRectMake(0, 0, textBounds.size.width, textBounds.size.height);
  UIView *view = [[UIView alloc] initWithFrame:viewFrame];
  [view addSubview:label];

  UIViewController *viewController = [UIViewController new];
  viewController.view = view;

我计划在弹出窗口中显示此视图控制器,因为从iOS 13弹出窗口视图包含箭头,我需要为标签设置布局约束以包括安全区域布局指南。我不确定如何以编程方式添加此约束。

0 个答案:

没有答案