安装第三方库

pod 'FLAnimatedImage'

引入头文件 FLAnimatedImage

#import "FLAnimatedImageView+WebCache.h"

新建一个FLAnimatedImageView

@property (strong, strong) FLAnimatedImageView *music_play_view;

 创建gif视图,可以使用本地文件或者url展示

    _music_play_view = [FLAnimatedImageView new];
    [self addSubview:_music_play_view];
    [_music_play_view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self);
        make.left.mas_equalTo(19);
        make.width.mas_equalTo(20);
        make.height.mas_equalTo(20);
    }];
    //文件在本地
    NSData *localData = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"PlayMusic.gif" ofType:nil]];
    //文件时URL
    //NSData *localData = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"https://xxx.xxx.xxx/media/active_page/1ffN9fa1_20190720092942_301.gif"]];
    FLAnimatedImage *animatedImage = [FLAnimatedImage animatedImageWithGIFData:localData];
    _music_play_view.animatedImage = animatedImage;

Logo

分享最新的 NVIDIA AI Software 资源以及活动/会议信息,精选收录AI相关技术内容,欢迎大家加入社区并参与讨论。

更多推荐