屏幕自动旋转和调节大小

1.新建工程名为RotateDemo , File->New->Project ->single View Application -> next


2.在view视图上添加两个Label,

//  RotateViewController.h #import <UIKit/UIKit.h>  @interface RotateViewController : UIViewController {     UILabel *upLabel;     UILabel *downLabel;     CGRect upFrame;     CGRect dowmFrame; } @end

- (void)viewDidLoad {     [super viewDidLoad]; 	// Do any additional setup after loading the view, typically from a nib.     upFrame = CGRectMake(10, 10, 300, 100);     dowmFrame = CGRectMake(10, 350, 300, 100); //    初始化Label     upLabel = [[UILabel alloc] initWithFrame:upFrame];     downLabel = [[UILabel alloc] initWithFrame:dowmFrame]; //    设置标题     [upLabel setText:@"在上面"];     [downLabel setText:@"在下面"]; //    设置字体大小     upLabel.font = [UIFont systemFontOfSize:48.0];     downLabel.font = [UIFont systemFontOfSize:48.0]; //    字体加粗     upLabel.font = [UIFont boldSystemFontOfSize:48];     downLabel.font = [UIFont boldSystemFontOfSize:48];      //    如果label标题很长,可以使用此方法让标题大小自动适合label宽度     /*     upLabel.adjustsFontSizeToFitWidth =YES;     downLabel.adjustsFontSizeToFitWidth = YES;     */      //    设置Label标题居中对其     upLabel.textAlignment=UITextAlignmentCenter;     downLabel.textAlignment = UITextAlignmentCenter; //    设置label标题颜色     [upLabel setTextColor:[UIColor blackColor]];     [downLabel setTextColor:[UIColor blueColor]];      //    设置Label透明度0是完全透明,1是不透明     upLabel.alpha = 0.9;     downLabel.alpha = 0.4; //    把label添加到视图上         [self.view addSubview:upLabel];     [self.view addSubview:downLabel]; }

你可能感兴趣的:(ios,command,application,iPhone,电话)