美文网首页就你这辣鸡还来开发我的iOS
iOS CoreGraphics gif图片DIY框架

iOS CoreGraphics gif图片DIY框架

作者: 一本大书 | 来源:发表于2018-09-12 14:54 被阅读38次

    使用方法

    1、在头部导入 #import "ZZCoreEmoji.h"
    2、创建一个画布、在画布上创建素材。
    素材支持移动、旋转、缩放、文字素材支持双击替换文字、并且可以自定义文字样式。

    效果
        // -----图片素材-----
        ZZMatterView *mView = [[ZZMatterView alloc]
                               initWithImage:[UIImage imageNamed:@"panda"]
                               center:CGPointMake(200, 200)];
        [self.canvasView addSubview:mView];
        [self.canvasView.matterViews addObject:mView];
    
        // -----文本素材-----
        ZZTextAttributes *attributes = [[ZZTextAttributes alloc]
                                        initWithText:@"哈哈哈\n呵呵额"
                                        font:[UIFont systemFontOfSize:40]
                                        textColor:[UIColor redColor]
                                        borderColor:[UIColor yellowColor]];
        UIImage *textImage = [UIImage zz_imageWithAttributes:attributes];
        mView = [[ZZMatterView alloc] initWithImage:textImage
                                             center:CGPointMake(100, 100)
                                               attributes:attributes];
        [self.canvasView addSubview:mView];
        [self.canvasView.matterViews addObject:mView];
    

    图片制作方法调用

    // 制作图片
        self.canvasView.currentView = nil;
        
        ZZDrawImageOptions *options = [[ZZDrawImageOptions alloc]
                                       initWithCanvasView:self.canvasView
                                       originalImage:self.iconView.image
                                       matterViews:self.canvasView.matterViews];
        
        ZZDrawImageManager *manager = [ZZDrawImageManager new];
        __weak typeof(self) weakSelf = self;
        [manager drawImageWithOptions:options complete:^(UIImage *image) {
    
        }];
    

    大致架构设计


    image.png

    Demo地址:https://github.com/Linzehua2015/ZZCoreEmoji

    相关文章

      网友评论

        本文标题:iOS CoreGraphics gif图片DIY框架

        本文链接:https://www.haomeiwen.com/subject/gmqzwftx.html