UIImageView与UIButton

应用场合

UIImageView主要用在只显示图片,没有点击事件的情况并且处理图片更加专业,动画例子:

    NSMutableArray *images = [NSMutableArray array];
    for (int i=0; i<sum; i++) {
        NSBundle *budle = [NSBundle mainBundle];
        NSString *nn = [NSString stringWithFormat:@"%@_%02d.jpg",name,i ];
        NSString *path =[budle pathForResource:nn ofType:nil];
        UIImage *image = [UIImage imageWithContentsOfFile:path];
        [images addObject:image];
    }
    self.Tom.animationImages =images;
    self.Tom.animationDuration = sum*0.06;
    self.Tom.animationRepeatCount = 1;
    [self.Tom startAnimating];
    [self.Tom performSelector:@selector(setAnimationImages:) withObject:nil afterDelay:self.Tom.animationDuration+1];

UIButton主要用于有点击事件。

相同点:

两者都能显示图片

区别:

UIImageView只能显示图片,UIButton既能显示图片又能显示文字,UIButton之所以既能显示图片又能显示文字,是因为其内部默认有两个控件一个是UIImageView一个UILabel,所以当用代码给按钮设置字体属性的时候利用UIButton的.TitleLabel返回这个UILabel设置。

UIButton可以显示两张图片(背景图片与前景图片)

UIButton继承自UIControl,UIControl有AddTarget方法,所以UIButton拥有处理点击事件的能力。(凡是继承自UIControl的控件都能监听点击事件)


转载于:https://my.oschina.net/renyunxiang/blog/323767

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值