您好,登錄后才能下訂單哦!
本來已經寫了很多,就因為切換頁面就沒有了,以后切之前得注意了 mac電腦的傷不起
UI里面有很多控件比如UIView UIControl UILabel UIButton UIScrollView UIWindow UIWebView UITabBar UITableView UITableViewCell UIToolbar UITextField UITextView UIImageView UIPageControl UIPickerView UIProgressView UIAlertView UISearchBar UISegmentedControl UISearchBar UISlider UISwitch UICollectionView 6.0 UICollectionReusableView等
控制器有
UIPageViewController UIPopoverController UIImagePickerController UINavigationController UISplitViewController UICollectionViewController UITableViewController
開在寫了,廢話少說,
先將UILabel UIView和UIResponder后面在寫,
UILabel的
- (void)viewDidLoad
{
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
UILabel *aLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 100, 280, 100)];
aLabel.backgroundColor = [UIColor greenColor];
aLabel.text = @"這是我在2013年的程序,今天也是我要寫ios、mac和操作系統相關的技術博文,我的bolg分別是(1)http://www.cnblogs.com/leevaboo(2)http://blog.csdn.net/leevaboo,(3)http://3660064.blog.51cto.com";
aLabel.textAlignment = NSTextAlignmentCenter;//左中右對其的模式 default is left
aLabel.textColor = [UIColor blueColor];//文本顏色default is blackColor
aLabel.font = [UIFont systemFontOfSize:20];//字體的大小default is 17
aLabel.shadowColor = [UIColor redColor];//陰影default is nil
aLabel.shadowOffset = CGSizeMake(0, 1);//陰影的位置,按照xy軸的坐標位置來,default is (0 -1)表示x = 0 ,y = -1 表示在陰影在正下方 x軸左到右是負到正,y上到下是負到正
aLabel.lineBreakMode = NSLineBreakByTruncatingTail;//文本超過label的邊界的文本截取方式default is NSLineBreakByTruncatingTail
aLabel.highlightedTextColor = [UIColor purpleColor];//設置文本的高亮顏色 default is nil
aLabel.highlighted = NO;//打開高亮default is NO
aLabel.userInteractionEnabled = NO;//是否交互.default is NP
aLabel.adjustsFontSizeToFitWidth = NO;//根據寬調整字體的大小 但是numberOfLines = 1;default is NO
aLabel.numberOfLines = 0;
float height = [aLabel.text sizeWithFont:aLabel.font constrainedToSize:CGSizeMake(280, 100000) lineBreakMode:NSLineBreakByWordWrapping].height;//根據字符串的長度和字號的大小和Label的寬度自動計算label的高度
aLabel.baselineAdjustment = UIBaselineAdjustmentAlignBaselines;//設置label的基準線
aLabel.frame = CGRectMake(20, 100, 280, height);
[self.view addSubview:aLabel];
[aLabel release];
// Do any additional setup after loading the view.
}
本來已經寫了很多,就因為切換頁面就沒有了,以后切之前得注意了 mac電腦的傷不起
UI里面有很多控件比如UIView UIControl UILabel UIButton UIScrollView UIWindow UIWebView UITabBar UITableView UITableViewCell UIToolbar UITextField UITextView UIImageView UIPageControl UIPickerView UIProgressView UIAlertView UISearchBar UISegmentedControl UISearchBar UISlider UISwitch UICollectionView 6.0 UICollectionReusableView等
控制器有
UIPageViewController UIPopoverController UIImagePickerController UINavigationController UISplitViewController UICollectionViewController UITableViewController
開在寫了,廢話少說,
先將UILabel UIView和UIResponder后面在寫,
UILabel的
- (void)viewDidLoad
{
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
UILabel *aLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 100, 280, 100)];
aLabel.backgroundColor = [UIColor greenColor];
aLabel.text = @"這是我在2013年的程序,今天也是我要寫ios、mac和操作系統相關的技術博文,我的bolg分別是(1)http://www.cnblogs.com/leevaboo(2)http://blog.csdn.net/leevaboo,(3)http://3660064.blog.51cto.com";
aLabel.textAlignment = NSTextAlignmentCenter;//左中右對其的模式 default is left
aLabel.textColor = [UIColor blueColor];//文本顏色default is blackColor
aLabel.font = [UIFont systemFontOfSize:20];//字體的大小default is 17
aLabel.shadowColor = [UIColor redColor];//陰影default is nil
aLabel.shadowOffset = CGSizeMake(0, 1);//陰影的位置,按照xy軸的坐標位置來,default is (0 -1)表示x = 0 ,y = -1 表示在陰影在正下方 x軸左到右是負到正,y上到下是負到正
aLabel.lineBreakMode = NSLineBreakByTruncatingTail;//文本超過label的邊界的文本截取方式default is NSLineBreakByTruncatingTail
aLabel.highlightedTextColor = [UIColor purpleColor];//設置文本的高亮顏色 default is nil
aLabel.highlighted = NO;//打開高亮default is NO
aLabel.userInteractionEnabled = NO;//是否交互.default is NP
aLabel.adjustsFontSizeToFitWidth = NO;//根據寬調整字體的大小 但是numberOfLines = 1;default is NO
aLabel.numberOfLines = 0;
float height = [aLabel.text sizeWithFont:aLabel.font constrainedToSize:CGSizeMake(280, 100000) lineBreakMode:NSLineBreakByWordWrapping].height;//根據字符串的長度和字號的大小和Label的寬度自動計算label的高度
aLabel.baselineAdjustment = UIBaselineAdjustmentAlignBaselines;//設置label的基準線
aLabel.frame = CGRectMake(20, 100, 280, height);
[self.view addSubview:aLabel];
[aLabel release];
// Do any additional setup after loading the view.
}
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。