"; NSString *string = @"这是一段中文测试文字,可以包含特殊符号。~!@#$%……&*()—— {}【】:;“”‘’《》,。?;、“”‘’《》"; label.text = [string UTF8String]; label.maxCharacterLength = 10; label.font = [UIFont systemFontOfSize:17]; label.backgroundColor = [UIColor blackColor]; label.textColor = [UIColor whiteColor]; [label setContentHuggingPriority:500 forAxis:UILayoutConstraintAxisVertical]; [self.view addSubview:label]; label.layer.borderColor = [UIColor redColor].CGColor; label.layer.borderWidth = 2; label.translatesAutoresizingMaskIntoConstraints = NO; [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-10-[label]-10-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(label)]]; [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-70-[label]" options:0 metrics:nil views:NSDictionaryOfVariableBindings(label)]]; [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-10-[bottomView]-10-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(bottomView)]]; [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[bottomView(50)]-20-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(bottomView)]];}- (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.}@end
免責聲明:若本站收錄的資源侵犯了您的權益,我們會及時刪除侵權內容,謝謝合作!