UI 一一 常用控件-UILabel,UIImageView

UI常用控件:

  • UIButton 按钮
  • UILabel 文本标签
  • UITextField文本输入框
  • UIImageView 图片显示
  • UIScrollView  滚动的控件
  • UITableView  表格
  • UICollectionView 九宫格
  • UIWebView 网页显示控件
  • UIAlertView  对话框(中间弹框)
  • UINavigationBar导航条
  • UIPageControl  分页控件
  • UITextView  能滚动的文字显示控件
  • UIActivityIndicator 圈圈
  • UISwitch 开关
  • UIActionSheet 底部弹框
  • UIDatePicker 日期选择器
  • UIToolbar  工具条
  • UIProgressView进度条
  • UISlider滑块
  • UISegmentControl 选项卡
  • UIPickerView 选择器

注意: 红色表明最常用,蓝色代表一般,黑色代表几乎不用


UILabel

UILabel极其常用,功能比较专一:显示文字


UILabel的常见属性:

@property(nonatomic,copy)  NSString     *text; 

  • 显示的文字

@property(nonatomic,retain)UIFont        *font; 

  • 字体

@property(nonatomic,retain)UIColor        *textColor; 

  • 文字颜色

@property(nonatomic)       NSTextAlignment    textAlignment; 

  • 对齐模式(比如左对齐、居中对齐、右对齐) 

@property(nonatomic)NSInteger numberOfLines; 

  • 文字行数

@property(nonatomic)       NSLineBreakMode    lineBreakMode;

  • 换行模式

UIFont

  • UIFont代表字体,常见创建方法有以下几个:
  • + (UIFont *)systemFontOfSize:(CGFloat)fontSize;  系统默认字体
  • + (UIFont *)boldSystemFontOfSize:(CGFloat)fontSize; 粗体
  • + (UIFont *)italicSystemFontOfSize:(CGFloat)fontSize; 斜体



UIImageView

UIImageView极其常用,功能比较专一:显示图片


UIImageView的常见属性

@property(nonatomic,retain)UIImage *image; 

  • 显示的图片


@property(nonatomic,copy)NSArray *animationImages; 

  • 显示的动画图片


@property(nonatomic)NSTimeInterval animationDuration; 

  • 动画图片的持续时间


@property(nonatomic)NSInteger      animationRepeatCount; 

  • 动画的播放次数(默认是0,代表无限播放)

@property(nonatomic)UIViewContentMode contentMode;  

设置图片的模式

有以下模式:

     UIViewContentModeRedraw, // 重新绘制 (核心绘图) drawRact

     

     //带有Scale,标明图片有可能被拉伸或压缩

     UIViewContentModeScaleToFill, // 完全的压缩或拉伸

     

     // Aspect 比例,缩放是带有比例的

     UIViewContentModeScaleAspectFit, //宽高比不变 Fit适应(显示整张图片)

     UIViewContentModeScaleAspectFill, //宽高比不变 Fill填充(显示部分图片,填充image大小)

     

     //不带有Scale,标明图片不可能被拉伸或压缩

     UIViewContentModeCenter,

     UIViewContentModeTop,

     UIViewContentModeBottom,

     UIViewContentModeLeft,

     UIViewContentModeRight,

     UIViewContentModeTopLeft,

     UIViewContentModeTopRight,

     UIViewContentModeBottomLeft,

     UIViewContentModeBottomRight,




UIImageView的常见方法

- (void)startAnimating; //开始动画

- (void)stopAnimating; //停止动画

- (BOOL)isAnimating; //是否正在执行动画


UIImageView设置frame的四种方法

    // 设置frame的方式

    // 方式一

      UIImageView *imageView = [[UIImageViewalloc] init];

      imageView.image = [UIImageimageNamed:@"1"];

     

//    imageView.frame = CGRectMake(100, 100, 267, 400);

//    imageView.frame = (CGRect){{100, 100},{267, 400}};

    

    


    // 方式二


    UIImageView *imageView = [[UIImageView alloc] init];

    // 创建一个UIImage对象

    UIImage *image = [UIImageimageNamed:@"1"];

    // 设置frame

    imageView.frame =CGRectMake(100,10, image.size.width, image.size.height);

    // 设置图片

    imageView.image = image;

    

    


    // 方式三

    // 创建一个UIImage对象

    UIImage *image = [UIImage imageNamed:@"1"];

    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(100,10, image.size.width, image.size.height)];

    imageView.image = image;

    

    

    // 方式四

    // 创建一个UIimageview对象

    // 注意: initWithImage默认就有尺寸--->图片的尺寸

    UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"1"]];

    

    // 改变位置

//    imageView.center = CGPointMake(200, 150);

    

    imageView.center =CGPointMake(self.view.frame.size.width * 0.5, self.view.frame.size.height * 0.5);

    

    [self.viewaddSubview:imageView];






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

white camel

感谢支持~

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值