你的位置:首页 > 操作系统

[操作系统]【代码笔记】把br!换成\n


代码:

复制代码
- (void)viewDidLoad{  [super viewDidLoad];  // Do any additional setup after loading the view.    //把<br!>换成\n  NSString *string=@"123<br!>456<br!>789";  NSString *newStr=[string stringByReplacingOccurrencesOfString:@"<br!>" withString:@"\n"];  NSString *newNewStr=[newStr stringByReplacingOccurrencesOfString:@"\n" withString:@"<br!>"];    UILabel *label=[[UILabel alloc]initWithFrame:CGRectMake(10, 100, 100, 200)];  label.backgroundColor=[UIColor redColor];  label.text=newNewStr;  //下面这个代码很重要,很重要的  label.numberOfLines=0;  [self.view addSubview:label];}
复制代码