Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (void)viewDidLoad {
- [super viewDidLoad];
- __auto_type appLabel = [UILabel new];
- appLabel.translatesAutoresizingMaskIntoConstraints = NO;
- appLabel.text = NSBundle.mainBundle.executablePath.lastPathComponent;
- [self.view addSubview:appLabel];
- __auto_type createLabel = ^{
- __auto_type l = [UILabel new];
- l.numberOfLines = 0;
- return l;
- };
- __auto_type screen = UIScreen.mainScreen;
- __auto_type scaleLabel = createLabel();
- scaleLabel.text = [NSString stringWithFormat:@"traits scale %.1lf\nscreen scale %.1lf\nscreen nativeScale %.1lf", self.traitCollection.displayScale, screen.scale, screen.nativeScale];
- __auto_type sizeLabel = createLabel();
- sizeLabel.text = [NSString stringWithFormat:@"fixed bounds %@\nnativeBounds %@", NSStringFromCGSize(screen.fixedCoordinateSpace.bounds.size), NSStringFromCGSize(screen.nativeBounds.size)];
- __auto_type verticalStack = [[UIStackView alloc] initWithArrangedSubviews:@[scaleLabel, sizeLabel]];
- verticalStack.axis = UILayoutConstraintAxisVertical;
- verticalStack.spacing = 10;
- verticalStack.translatesAutoresizingMaskIntoConstraints = NO;
- [self.view addSubview:verticalStack];
- [NSLayoutConstraint activateConstraints:@[[appLabel.centerXAnchor constraintEqualToAnchor:self.view.centerXAnchor],
- [appLabel.topAnchor constraintEqualToAnchor:self.topLayoutGuide.bottomAnchor],
- [verticalStack.centerXAnchor constraintEqualToAnchor:self.view.centerXAnchor],
- [verticalStack.centerYAnchor constraintEqualToAnchor:self.view.centerYAnchor]]];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement