UILabel和UIImageView的使用

UILabel的使用

主要功能:显示文本用于内容提示
常用属性
NSString         *text; //UILabel显示的文本内容;

UIColor          *textColor; //文本显示的颜色

CGSize           *shadowColor; //文本显示的阴影

NSTextAlignment   textAlignment;//文本对齐方式(左对齐,居中,右对齐)

UIColor          *highlightedtextColor;//文本高亮是的显示颜色

BOOL             highlighted; //设置文本高亮

NSLineBreakMode  lineBreakMode; //如果需要多行显示需要设置这个属性

BOOL             userInteractionEnabled; //UILabel是否允许交互

NSInteger        numberOfLines;// UILabel文本显示的行数,如果是0表示不限制

BOOL             adjustsFontSizeToFitWidth;//根据UILabel大小调整字体大小

UIImageView 的使用

主要功能:在应用程序中主要用于显示图片的视图

常用属性

UIImage          *image;
//UIImageView显示的图片内容,默认是nil

UIImage          *highlightedImage;
//当UIImageView被选中的时候显示的图片内容 默认是nil

BOOL             userInteractionEnabled;
//UIImageView及其上得元素是否交互(非常重要)

BOOL             highlighted;//UIImageView是否是高亮状态

初始化方法

- (id)initWithImage:(UIImage*)image;
- (id)initWithImage:(UIImage*)image highlightedImage:(UIImage*)highlightedImage;

制作动画播放效果

#import "ViewController.h"

@interface ViewController ()

@property(strong,nonatomic) UIImageView *imageView;

@end

@implementation ViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    //定义一个存放图片对象的数组
    NSArray *imagesArray = [[NSArray alloc] initWithObjects:
                            [UIImage imageNamed:@"xiaohai.jpg"],
                            [UIImage imageNamed:@"xiaogou.jpg"],
                            [UIImage imageNamed:@"songshu.jpg"],
                            nil];
     //初始化一个图片视图
    _imageView = [[UIImageView alloc] initWithFrame:
    CGRectMake(100, 150, 150, 180)];

    //将图片数组赋值给图片视图的动画图片
    _imageView.animationImages = imagesArray;

    //设置图片按照原始比例缩放。保持纵横比
    _imageView.contentMode = UIViewContentModeScaleAspectFit;

    //切换动作的持续时间,秒
    _imageView.animationDuration = 2;

    //动画的重复次数,0时自由循环
    _imageView.animationRepeatCount = 0;

    [self.view addSubview:_imageView];

}
- (IBAction)playAnimation:(id)sender {
    if (_imageView.isAnimating) {
        [_imageView stopAnimating];//暂停播放
    }else{
        [_imageView startAnimating];//开始播放
    }
}

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值