#import "ViewController.h"
@interface Viewcontroller ()
@property (Nonatomic,strong) UILabel *labelone;
@property (Nonatomic,strong) UILabel *labeltwo;
@property (nonatomic,copy) NSString *str;
@end
@implementation Viewcontroller
-(void) Viewdidload {
[Super Viewdidload];
Additional setup after loading the view, typically from a nib.
NSString *[email protected] "SouFun is the world's largest real estate home network platform, page views and traffic in similar sites in the absolute leading position. With 9,000 employees, the network covers more than 300 cities and has subsidiaries and offices in more than 100 cities in China. September 2010 SouFun (stock code Sfun) successfully listed on the New York Stock Exchange. SouFun is the world's largest real estate home network platform, page views and traffic in similar sites in the absolute leading position. With 9,000 employees, the network covers more than 300 cities and has subsidiaries and offices in more than 100 cities in China. September 2010 SouFun (stock code Sfun) successfully listed on the New York Stock Exchange. ";
Self.str=strone;
Self.labelone=[[uilabel Alloc]init];
self.labelone.numberoflines=0;
Self.labelone.font=[uifont systemfontofsize:14];
Self.labelone.textalignment=nstextalignmentcenter;
Self.labelone.text=strone;
Self.labeltwo=[[uilabel Alloc]init];
self.labeltwo.numberoflines=0;
Self.labeltwo.font=[uifont SYSTEMFONTOFSIZE:20];
Self.labeltwo.textalignment=nstextalignmentcenter;
Self.labeltwo.text=strone;
[Self.view AddSubview:self.labelOne];
[Self.view AddSubview:self.labelTwo];
}
-(void) didreceivememorywarning {
[Super didreceivememorywarning];
Dispose of any resources the can be recreated.
}
-(void) Viewwillappear: (BOOL) animated{
CGRect labeloneframe=[self.str boundingrectwithsize:cgsizemake (0) options: Nsstringdrawinguseslinefragmentorigin Attributes:@{nsfontattributename:[uifont systemFontOfSize:14]} Context:nil] ; [Super viewwillappear:animated];
Cgpoint Pointone=cgpointmake (100, 50);
CGRect Labelframe;
Labelframe.origin=pointone;
Labelframe.size=labeloneframe.size;
Self.labelone.frame=labelframe;
CGRect labeltwoframe=[self.str boundingrectwithsize:cgsizemake (0) options: Nsstringdrawinguseslinefragmentorigin Attributes:@{nsfontattributename:[uifont systemFontOfSize:20]} Context:nil] ;
Cgpoint Pointtwo=cgpointmake (self.labelone.frame.origin.x, Cgrectgetmaxy (self.labelOne.frame));
Labelframe.origin=pointtwo;
Labelframe.size=labeltwoframe.size;
Self.labeltwo.frame=labelframe;
}
@end
In fact, the automatic layout doesn't have to be so troublesome.
Label in iOS sets the next label's frame according to the contents of the previous label