Skip to content

Commit

Permalink
Merge pull request #552 from longitachi/zl/text_stickers
Browse files Browse the repository at this point in the history
Text stickers
  • Loading branch information
longitachi authored Nov 18, 2020
2 parents 15fe4be + f84fad2 commit 5a8ee9e
Show file tree
Hide file tree
Showing 35 changed files with 1,236 additions and 153 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ iOSInjectionProject/
Carthage/Build
Carthage/Checkouts

### FLEX
Example/Example/Classes

# End of https://www.gitignore.io/api/cocoapods,objective-c
Sources/.DS_Store
.DS_Store
32 changes: 27 additions & 5 deletions Example/Example/PhotoConfigureCNViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ class PhotoConfigureCNViewController: UIViewController {

var editImageClipToolSwitch: UISwitch!

var editImageTextStickerToolSwitch: UISwitch!

var editImageMosaicToolSwitch: UISwitch!

var editImageFilterToolSwitch: UISwitch!
Expand Down Expand Up @@ -513,11 +515,28 @@ class PhotoConfigureCNViewController: UIViewController {
make.centerY.equalTo(clipToolLabel)
}

// 裁剪
// 文本
let textStickerToolLabel = createLabel("文字")
self.editImageToolView.addSubview(textStickerToolLabel)
textStickerToolLabel.snp.makeConstraints { (make) in
make.top.equalTo(clipToolLabel.snp.bottom).offset(velSpacing)
make.left.equalTo(self.editImageToolView)
}

self.editImageTextStickerToolSwitch = UISwitch()
self.editImageTextStickerToolSwitch.isOn = config.editImageTools.contains(.textSticker)
self.editImageTextStickerToolSwitch.addTarget(self, action: #selector(textStickerToolChanged), for: .valueChanged)
self.editImageToolView.addSubview(self.editImageTextStickerToolSwitch)
self.editImageTextStickerToolSwitch.snp.makeConstraints { (make) in
make.left.equalTo(textStickerToolLabel.snp.right).offset(horSpacing)
make.centerY.equalTo(textStickerToolLabel)
}

// 马赛克
let mosaicToolLabel = createLabel("马赛克")
self.editImageToolView.addSubview(mosaicToolLabel)
mosaicToolLabel.snp.makeConstraints { (make) in
make.top.equalTo(clipToolLabel.snp.bottom).offset(velSpacing)
make.top.equalTo(textStickerToolLabel.snp.bottom).offset(velSpacing)
make.left.equalTo(self.editImageToolView)
}

Expand Down Expand Up @@ -550,11 +569,10 @@ class PhotoConfigureCNViewController: UIViewController {

// 编辑视频开关
editVideoLabel = createLabel("允许编辑视频")
editVideoLabel.tag = 1000
containerView.addSubview(editVideoLabel)
editVideoLabel.snp.makeConstraints { (make) in
if config.allowEditImage {
make.top.equalTo(editImageLabel.snp.bottom).offset(180)
make.top.equalTo(editImageLabel.snp.bottom).offset(225)
} else {
make.top.equalTo(editImageLabel.snp.bottom).offset(velSpacing)
}
Expand Down Expand Up @@ -843,7 +861,7 @@ class PhotoConfigureCNViewController: UIViewController {
self.editImageToolView.alpha = self.config.allowEditImage ? 1 : 0
self.editVideoLabel.snp.updateConstraints({ (make) in
if self.config.allowEditImage {
make.top.equalTo(self.editImageLabel.snp.bottom).offset(180)
make.top.equalTo(self.editImageLabel.snp.bottom).offset(225)
} else {
make.top.equalTo(self.editImageLabel.snp.bottom).offset(20)
}
Expand All @@ -860,6 +878,10 @@ class PhotoConfigureCNViewController: UIViewController {
config.editImageTools = ZLEditImageViewController.EditImageTool(rawValue: config.editImageTools.rawValue ^ ZLEditImageViewController.EditImageTool.clip.rawValue)
}

@objc func textStickerToolChanged() {
config.editImageTools = ZLEditImageViewController.EditImageTool(rawValue: config.editImageTools.rawValue ^ ZLEditImageViewController.EditImageTool.textSticker.rawValue)
}

@objc func mosaicToolChanged() {
config.editImageTools = ZLEditImageViewController.EditImageTool(rawValue: config.editImageTools.rawValue ^ ZLEditImageViewController.EditImageTool.mosaic.rawValue)
}
Expand Down
32 changes: 27 additions & 5 deletions Example/Example/PhotoConfigureViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ class PhotoConfigureViewController: UIViewController {

var editImageClipToolSwitch: UISwitch!

var editImageTextStickerToolSwitch: UISwitch!

var editImageMosaicToolSwitch: UISwitch!

var editImageFilterToolSwitch: UISwitch!
Expand Down Expand Up @@ -513,11 +515,28 @@ class PhotoConfigureViewController: UIViewController {
make.centerY.equalTo(clipToolLabel)
}

// 裁剪
// 文本
let textStickerToolLabel = createLabel("Text sticker")
self.editImageToolView.addSubview(textStickerToolLabel)
textStickerToolLabel.snp.makeConstraints { (make) in
make.top.equalTo(clipToolLabel.snp.bottom).offset(velSpacing)
make.left.equalTo(self.editImageToolView)
}

self.editImageTextStickerToolSwitch = UISwitch()
self.editImageTextStickerToolSwitch.isOn = config.editImageTools.contains(.textSticker)
self.editImageTextStickerToolSwitch.addTarget(self, action: #selector(textStickerToolChanged), for: .valueChanged)
self.editImageToolView.addSubview(self.editImageTextStickerToolSwitch)
self.editImageTextStickerToolSwitch.snp.makeConstraints { (make) in
make.left.equalTo(textStickerToolLabel.snp.right).offset(horSpacing)
make.centerY.equalTo(textStickerToolLabel)
}

// 马赛克
let mosaicToolLabel = createLabel("Mosaic")
self.editImageToolView.addSubview(mosaicToolLabel)
mosaicToolLabel.snp.makeConstraints { (make) in
make.top.equalTo(clipToolLabel.snp.bottom).offset(velSpacing)
make.top.equalTo(textStickerToolLabel.snp.bottom).offset(velSpacing)
make.left.equalTo(self.editImageToolView)
}

Expand Down Expand Up @@ -550,11 +569,10 @@ class PhotoConfigureViewController: UIViewController {

// 编辑视频开关
editVideoLabel = createLabel("Edit video")
editVideoLabel.tag = 1000
containerView.addSubview(editVideoLabel)
editVideoLabel.snp.makeConstraints { (make) in
if config.allowEditImage {
make.top.equalTo(editImageLabel.snp.bottom).offset(180)
make.top.equalTo(editImageLabel.snp.bottom).offset(225)
} else {
make.top.equalTo(editImageLabel.snp.bottom).offset(velSpacing)
}
Expand Down Expand Up @@ -843,7 +861,7 @@ class PhotoConfigureViewController: UIViewController {
self.editImageToolView.alpha = self.config.allowEditImage ? 1 : 0
self.editVideoLabel.snp.updateConstraints({ (make) in
if self.config.allowEditImage {
make.top.equalTo(self.editImageLabel.snp.bottom).offset(180)
make.top.equalTo(self.editImageLabel.snp.bottom).offset(225)
} else {
make.top.equalTo(self.editImageLabel.snp.bottom).offset(20)
}
Expand All @@ -860,6 +878,10 @@ class PhotoConfigureViewController: UIViewController {
config.editImageTools = ZLEditImageViewController.EditImageTool(rawValue: config.editImageTools.rawValue ^ ZLEditImageViewController.EditImageTool.clip.rawValue)
}

@objc func textStickerToolChanged() {
config.editImageTools = ZLEditImageViewController.EditImageTool(rawValue: config.editImageTools.rawValue ^ ZLEditImageViewController.EditImageTool.textSticker.rawValue)
}

@objc func mosaicToolChanged() {
config.editImageTools = ZLEditImageViewController.EditImageTool(rawValue: config.editImageTools.rawValue ^ ZLEditImageViewController.EditImageTool.mosaic.rawValue)
}
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[![Version](https://img.shields.io/cocoapods/v/ZLPhotoBrowser.svg?style=flat)](http://cocoadocs.org/docsets/ZLPhotoBrowser)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) 
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-brightgreen.svg?style=flat)](https://github.com/Carthage/Carthage)
[![SwiftPM compatible](https://img.shields.io/badge/SwiftPM-compatible-brightgreen.svg)](https://swift.org/package-manager/)
[![License](https://img.shields.io/cocoapods/l/ZLPhotoBrowser.svg?style=flat)](http://cocoadocs.org/docsets/ZLPhotoBrowser)
[![Platform](https://img.shields.io/cocoapods/p/ZLPhotoBrowser.svg?style=flat)](http://cocoadocs.org/docsets/ZLPhotoBrowser)
![Language](https://img.shields.io/badge/Language-%20Swift%20-blue.svg)
Expand Down Expand Up @@ -34,7 +35,7 @@ Detailed usage of `Swift` and `OC`, please refer to [Wiki](https://github.com/lo
- [x] Image/Gif/LivePhoto/Video Support.
- [x] Customize the maximum number of previews or selection, the maximum and minimum optional duration of the video.
- [x] Customize the number of columns displayed in each row.
- [x] Image editor (Draw/Crop/Mosaic/Filter), (Draw color can be customized; Crop ratio can be customized; Filter effect can be customized; You can choose the editing tool you want).
- [x] Image editor (Draw/Crop/Text sticker/Mosaic/Filter), (Draw color can be customized; Crop ratio can be customized; Filter effect can be customized; You can choose the editing tool you want).
- [x] Video editor.
- [x] Custom camera.
- [x] Multi-language.
Expand All @@ -46,7 +47,7 @@ Detailed usage of `Swift` and `OC`, please refer to [Wiki](https://github.com/lo
- [x] The color of each part of the framework can be customized (Provide dynamic color can support light/dark mode).
- [x] Customize images.

> If you have good needs and suggestions in use, or encounter any bugs, please feel free to issue and I will reply in time
> If you have good needs and suggestions in use, or encounter any bugs, please create an issue and I will reply in time.
### <a id="Requirements"></a>Requirements
* iOS 10.0
Expand Down Expand Up @@ -94,6 +95,7 @@ Detailed usage of `Swift` and `OC`, please refer to [Wiki](https://github.com/lo
Support iOS14 limited authority.
Provides the ability to preview PHAsset, local images and videos, network images and videos together.
Optimize some UI effects.
Support show image crop vc directly.
● 4.0.8:
Add filter to image editor.
● 4.0.7:
Expand Down Expand Up @@ -152,7 +154,7 @@ $ carthage update ZLPhotoBrowser

#### Swift Package Manager
1. Select File > Swift Packages > Add Package Dependency. Enter https://github.com/longitachi/ZLPhotoBrowser.git in the "Choose Package Repository" dialog.
2. In the next page, specify the version resolving rule as "Up to Next Major" with "4.0.8" as its earliest version.
2. In the next page, specify the version resolving rule as "Up to Next Major" with "4.0.9" as its earliest version.
3. After Xcode checking out the source and resolving the version, you can choose the "ZLPhotoBrowser" library and add it to your app target.

### <a id="DemoEffect"></a> Demo Effect
Expand Down
9 changes: 5 additions & 4 deletions README_CN.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[![Version](https://img.shields.io/cocoapods/v/ZLPhotoBrowser.svg?style=flat)](http://cocoadocs.org/docsets/ZLPhotoBrowser)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)&nbsp;
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-brightgreen.svg?style=flat)](https://github.com/Carthage/Carthage)
[![SwiftPM compatible](https://img.shields.io/badge/SwiftPM-compatible-brightgreen.svg)](https://swift.org/package-manager/)
[![License](https://img.shields.io/cocoapods/l/ZLPhotoBrowser.svg?style=flat)](http://cocoadocs.org/docsets/ZLPhotoBrowser)
[![Platform](https://img.shields.io/cocoapods/p/ZLPhotoBrowser.svg?style=flat)](http://cocoadocs.org/docsets/ZLPhotoBrowser)
![Language](https://img.shields.io/badge/Language-%20Swift%20-blue.svg)
Expand Down Expand Up @@ -38,7 +39,7 @@
- [x] 图片/Gif/LivePhoto/Video 混合选择
- [x] 自定义最大预览数/选择数/视频最大最小可选时长,控制可否选择原图
- [x] 自定义每行显示列数
- [x] 图片编辑(涂鸦/裁剪/马赛克/滤镜)(图片编辑可编辑多张;涂鸦颜色可自定义;裁剪比例可自定义;滤镜效果可自定义;编辑工具可根据需要自行选择)
- [x] 图片编辑(涂鸦/裁剪/添加文字/马赛克/滤镜)(图片编辑可编辑多张;涂鸦/文字颜色可自定义;裁剪比例可自定义;滤镜效果可自定义;编辑工具可根据需要自行选择)
- [x] 视频编辑(自定义最大裁剪时长)(效果参照微信视频编辑;支持编辑本地视频)
- [x] 自定义相机(效果参照微信拍照,点击拍照、长按拍摄;上滑调整焦距;可设置最大/最小录制时间及视频分辨率;可设置闪光灯模式及视频导出格式;可根据自己需要控制是否使用自定义相机)
- [x] 多语言国际化支持(中文简/繁,英文,日文,开发者可选根据系统或自己指定,多语言文案可自定义)
Expand Down Expand Up @@ -96,7 +97,7 @@
### <a id="更新日志"></a>更新日志
> [更多更新日志](https://github.com/longitachi/ZLPhotoBrowser/blob/master/UPDATELOG.md)
```
● 4.0.9: 支持更多国家的语言; 完善iOS14 limited authority 权限的适配; 提供可以同时预览PHAsset、本地图片/视频及网络图片/视频的功能; 优化部分UI效果;
● 4.0.9: 支持更多国家的语言; 完善iOS14 limited authority 权限的适配; 提供可以同时预览PHAsset、本地图片/视频及网络图片/视频的功能; 优化部分UI效果; 编辑图片可直接跳转裁剪界面;
● 4.0.8: 编辑图片添加滤镜功能;
● 4.0.7: 支持设置图片裁剪比例; 自定义相机支持录制时切换摄像头; 新增已选照片边框功能; 新增是否允许预览大图功能;其他细节优化及已知bug修复;
● 4.0.5: 适配iOS14 limited权限; 优化图片预览显示; 优化大长/宽图编辑;
Expand All @@ -122,7 +123,7 @@

* Swift Package Manager (该方式集成暂时有问题,图片及多语言资源无法读取,请暂时先用其他方式)
* 1. 选择 File > Swift Packages > Add Package Dependency,输入 `https://github.com/longitachi/ZLPhotoBrowser.git`
* 2. 输入对应版本号(SPM 最低版本为 `4.0.5`
* 2. 输入对应版本号(SPM 最低版本为 `4.0.9`
* 3. 等Xcode下载完成后确定即可

### <a id="效果图"></a> 效果图
Expand Down
1 change: 0 additions & 1 deletion Sources/Edit/ZLClipImageViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,6 @@ class ZLClipImageViewController: UIViewController {
self.resetTimer = nil
}


func moveClipContentToCenter() {
let maxClipRect = self.maxClipFrame
var clipRect = self.clipBoxFrame
Expand Down
Loading

0 comments on commit 5a8ee9e

Please sign in to comment.