頭文件:this
#import <UIKit/UIKit.h>atom
@interface ViewController : UIViewControllerspa
@property (nonatomic,strong) UILabel *myLabel;it
@endio
實現:class
#import "ViewController.h"import
@interfaceViewController ()im
@enddi
@implementation ViewController文件
- (void)viewDidLoad
{
[superviewDidLoad];
CGRect lableFrame = CGRectMake(0.0f,0.0f,100.0f,500.0f);
self.myLabel = [[UILabel alloc] initWithFrame:lableFrame];
self.myLabel.text = @"show this text in iPhone,something like that,I just want to make the text longer.";
self.myLabel.font = [UIFontboldSystemFontOfSize:14.0f];
self.myLabel.numberOfLines = 9; //只增大labelFrame的高度不行,
//要配合這個property使用。
//self.myLabel.adjustsFontSizeToFitWidth = YES;//這個屬性會根據labelFramed的高度從新設置子的大小,來適應其高度,可是隻有在numberOfLines爲1的時候有做用。
self.myLabel.shadowColor = [UIColorredColor];
self.myLabel.shadowOffset = CGSizeMake(1.0f, 2.0f);//陰影爲向右1point,向下2points.若設置爲(-1.0f, -2.0f),則爲向左向上。
[self.myLabel sizeToFit];
self.myLabel.textAlignment = NSTextAlignmentCenter;
self.myLabel.center = self.view.center;
[self.view addSubview:self.myLabel];
}
- (void)didReceiveMemoryWarning
{
[superdidReceiveMemoryWarning];
}
@end