GithubHelp home page GithubHelp logo

jjz / stitchingimage Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zhengjinghua/stitchingimage

0.0 2.0 0.0 803 KB

iOS 仿微信群组封面拼接控件, 直接拖进项目就可使用, 支持 CocoaPods 安装. WeChat-like, drop-in version, stitching mage

License: MIT License

Objective-C 95.63% Ruby 4.37%

stitchingimage's Introduction

English Guide

说明

类似微信群组封面拼接, 适用于聊天项目中, 之前翻遍了整个 Github 没找着, 就自己整了一个, 顺便开源.

Made with ❤️ by The EST Group - We design and build: the Future!

screenshot

系统要求

  • iOS7+ project
  • ARC project

安装

CocoaPods 安装

将下面代码复制进你的 Podfile 文件中

pod 'StitchingImage', :git => 'https://github.com/zhengjinghua/StitchingImage.git'

手工安装

下载 此项目, 并将该项目里的 Classes 文件夹里的所有文件复制进你的项目中, 然后在需要调用此项目的地方引入 #import "StitchingImage.h" .

使用

1. 收集头像数组

// 将你要拼接的头像文件放入到一个 NSMutableArray 中
NSMutableArray *imageViews = [[NSMutableArray alloc] init];
    
UIImageView *imageView_1 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
imageView_1.image = [UIImage imageNamed:@"1.jpg"];
[imageViews addObject:imageView_1];
    
UIImageView *imageView_2 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
imageView_2.image = [UIImage imageNamed:@"2.jpg"];
[imageViews addObject:imageView_2];

2. 准备好画布

// 生成一个背景 canvasView, 用于存放拼接好的群组封面, 相当于背景.
UIImageView *canvasView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
canvasView.layer.cornerRadius = 10;
canvasView.layer.masksToBounds = YES;
canvasView.backgroundColor = [UIColor colorWithWhite:0.839 alpha:1.000];

3. 绘画并生成

// 现在你可以调用以下方法, 将用户的头像画到指定的 canvasView 上
UIImageView *coverImage = [[StitchingImage alloc] stitchingOnImageView:canvasView withImageViews:imageViews];

[self.view addSubview:coverImage];

4. 修改 Margin

// 如果你想自定义生成的群组封面里的 margin 值, 你可以调用以下方法
UIImageView *coverImage = [[StitchingImage alloc] stitchingOnImageView:canvasView withImageViews:imageViews marginValue:15.0f];

[self.view addSubview:coverImage];

协议

StitchingImage 被许可在 MIT 协议下使用. 查阅 LICENSE 文件来获得更多信息.


README (English)

Introduction

Stitching image just like WeChat group chat's cover

Made with ❤️ by The EST Group - We design and build: the Future!

Requirements

  • iOS7+ project
  • ARC project

Install

CocoaPods

If you're using CocoaPods (You are not?! You should!!) just add

pod 'StitchingImage', :git => 'https://github.com/zhengjinghua/StitchingImage.git'

into your Podfile file.

Manually

Download the project and copy the Classes folder into your project and then simply #import "StitchingImage.h" in the file(s) you would like to use it in.

Usage

1. Create NSMutableArray for image views

NSMutableArray *imageViews = [[NSMutableArray alloc] init];
    
UIImageView *imageView_1 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
imageView_1.image = [UIImage imageNamed:@"1.jpg"];
[imageViews addObject:imageView_1];
    
UIImageView *imageView_2 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
imageView_2.image = [UIImage imageNamed:@"2.jpg"];
[imageViews addObject:imageView_2];

2. Create a canvasView

UIImageView *canvasView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
canvasView.layer.cornerRadius = 10;
canvasView.layer.masksToBounds = YES;
canvasView.backgroundColor = [UIColor colorWithWhite:0.839 alpha:1.000];

3. Stitching images

UIImageView *coverImage = [[StitchingImage alloc] stitchingOnImageView:canvasView withImageViews:imageViews];

[self.view addSubview:coverImage];

4. Change margin value

UIImageView *coverImage = [[StitchingImage alloc] stitchingOnImageView:canvasView withImageViews:imageViews marginValue:15.0f];

[self.view addSubview:coverImage];

License

StitchingImage is available under the MIT license. See the LICENSE file for more info.

stitchingimage's People

Contributors

zhengjinghua avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.