IOS学习之自动布局UIScrollView+UILabel

来源:互联网 发布:三星网络电视官网 编辑:程序博客网 时间:2024/05/02 09:04

1.效果图


2.View层级

UIView ==> UIScrollView ==> UIView ==> UILabel


注意:1.UIScrollView里需要放一个UIView

        2.UIScrollView里UIView高度错误问题到Label自动布局完自动OK

3.代码

#import "ViewController.h"@interface ViewController ()@property (weak, nonatomic) IBOutlet UILabel *label;@end@implementation ViewController- (void)viewDidLoad {    [super viewDidLoad];    NSMutableString *mutableString=[[NSMutableString alloc]init];        for(int i=1;i<=48;i++){        [mutableString appendFormat:[NSString stringWithFormat:@"%@.%@\n",[NSString stringWithFormat:@"%d",i],@"=====测试测试====="]];    }        _label.text= [mutableString substringToIndex:[mutableString length]-1];}- (void)didReceiveMemoryWarning {    [super didReceiveMemoryWarning];}@end


0 0