温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

IOS#UI之UILabel

发布时间:2020-05-28 02:39:24 来源:网络 阅读:560 作者:leevaboo 栏目:移动开发

 本来已经写了很多,就因为切换页面就没有了,以后切之前得注意了 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 UIViewUIResponder后面在写,

 

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年的程序,今天也是我要写iosmac和操作系统相关的技术博文,我的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 = 1default 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 UIViewUIResponder后面在写,

 

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年的程序,今天也是我要写iosmac和操作系统相关的技术博文,我的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 = 1default 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.

}

 

IOS#UI之UILabel

 

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI