@@ -86,7 +86,7 @@ open class ZLEditImageViewController: UIViewController {
86
86
87
87
public var drawColViewH : CGFloat = 50
88
88
89
- public var filterColViewH : CGFloat = 80
89
+ public var filterColViewH : CGFloat = 90
90
90
91
91
public var adjustColViewH : CGFloat = 60
92
92
@@ -136,7 +136,7 @@ open class ZLEditImageViewController: UIViewController {
136
136
137
137
open lazy var cancelBtn : ZLEnlargeButton = {
138
138
let btn = ZLEnlargeButton ( type: . custom)
139
- btn. setImage ( getImage ( " zl_retake " ) , for: . normal)
139
+ btn. setImage ( . zl . getImage ( " zl_retake " ) , for: . normal)
140
140
btn. addTarget ( self , action: #selector( cancelBtnClick) , for: . touchUpInside)
141
141
btn. adjustsImageWhenHighlighted = false
142
142
btn. enlargeInset = 30
@@ -157,8 +157,8 @@ open class ZLEditImageViewController: UIViewController {
157
157
158
158
open lazy var revokeBtn : UIButton = {
159
159
let btn = UIButton ( type: . custom)
160
- btn. setImage ( getImage ( " zl_revoke_disable " ) , for: . disabled)
161
- btn. setImage ( getImage ( " zl_revoke " ) , for: . normal)
160
+ btn. setImage ( . zl . getImage ( " zl_revoke_disable " ) , for: . disabled)
161
+ btn. setImage ( . zl . getImage ( " zl_revoke " ) , for: . normal)
162
162
btn. adjustsImageWhenHighlighted = false
163
163
btn. isEnabled = false
164
164
btn. isHidden = true
@@ -200,7 +200,7 @@ open class ZLEditImageViewController: UIViewController {
200
200
return view
201
201
} ( )
202
202
203
- open lazy var ashbinImgView = UIImageView ( image: getImage ( " zl_ashbin " ) , highlightedImage: getImage ( " zl_ashbin_open " ) )
203
+ open lazy var ashbinImgView = UIImageView ( image: . zl . getImage ( " zl_ashbin " ) , highlightedImage: . zl . getImage ( " zl_ashbin_open " ) )
204
204
205
205
var adjustSlider : ZLAdjustSlider ?
206
206
@@ -392,11 +392,11 @@ open class ZLEditImageViewController: UIViewController {
392
392
393
393
var stickers : [ UIView ? ] = Array ( repeating: nil , count: teStic. count + imStic. count)
394
394
teStic. forEach { cache in
395
- let v = ZLTextStickerView ( from : cache. state)
395
+ let v = ZLTextStickerView ( state : cache. state)
396
396
stickers [ cache. index] = v
397
397
}
398
398
imStic. forEach { cache in
399
- let v = ZLImageStickerView ( from : cache. state)
399
+ let v = ZLImageStickerView ( state : cache. state)
400
400
stickers [ cache. index] = v
401
401
}
402
402
@@ -439,18 +439,18 @@ open class ZLEditImageViewController: UIViewController {
439
439
topShadowLayer. frame = topShadowView. bounds
440
440
cancelBtn. frame = CGRect ( x: 30 , y: insets. top + 10 , width: 28 , height: 28 )
441
441
442
- bottomShadowView. frame = CGRect ( x: 0 , y: view. zl. height - 140 - insets. bottom, width: view. zl. width, height: 140 + insets. bottom)
442
+ bottomShadowView. frame = CGRect ( x: 0 , y: view. zl. height - 150 - insets. bottom, width: view. zl. width, height: 150 + insets. bottom)
443
443
bottomShadowLayer. frame = bottomShadowView. bounds
444
444
445
445
if canRedo, let redoBtn = redoBtn {
446
- redoBtn. frame = CGRect ( x: view. zl. width - 15 - 35 , y: 30 , width: 35 , height: 30 )
447
- revokeBtn. frame = CGRect ( x: redoBtn. zl. left - 10 - 35 , y: 30 , width: 35 , height: 30 )
446
+ redoBtn. frame = CGRect ( x: view. zl. width - 15 - 35 , y: 40 , width: 35 , height: 30 )
447
+ revokeBtn. frame = CGRect ( x: redoBtn. zl. left - 10 - 35 , y: 40 , width: 35 , height: 30 )
448
448
} else {
449
- revokeBtn. frame = CGRect ( x: view. zl. width - 15 - 35 , y: 30 , width: 35 , height: 30 )
449
+ revokeBtn. frame = CGRect ( x: view. zl. width - 15 - 35 , y: 40 , width: 35 , height: 30 )
450
450
}
451
- drawColorCollectionView? . frame = CGRect ( x: 20 , y: 20 , width: revokeBtn. zl. left - 20 - 10 , height: drawColViewH)
451
+ drawColorCollectionView? . frame = CGRect ( x: 20 , y: 30 , width: revokeBtn. zl. left - 20 - 10 , height: drawColViewH)
452
452
453
- adjustCollectionView? . frame = CGRect ( x: 20 , y: 10 , width: view. zl. width - 40 , height: adjustColViewH)
453
+ adjustCollectionView? . frame = CGRect ( x: 20 , y: 20 , width: view. zl. width - 40 , height: adjustColViewH)
454
454
if ZLImageEditorUIConfiguration . default ( ) . adjustSliderType == . vertical {
455
455
adjustSlider? . frame = CGRect ( x: view. zl. width - 60 , y: view. zl. height / 2 - 100 , width: 60 , height: 200 )
456
456
} else {
@@ -479,7 +479,7 @@ open class ZLEditImageViewController: UIViewController {
479
479
height: 25
480
480
)
481
481
482
- let toolY : CGFloat = 85
482
+ let toolY : CGFloat = 95
483
483
484
484
let doneBtnH = ZLImageEditorLayout . bottomToolBtnH
485
485
let doneBtnW = localLanguageTextValue ( . editFinish) . zl. boundingRect ( font: ZLImageEditorLayout . bottomToolTitleFont, limitSize: CGSize ( width: CGFloat . greatestFiniteMagnitude, height: doneBtnH) ) . width + 20
@@ -592,10 +592,10 @@ open class ZLEditImageViewController: UIViewController {
592
592
593
593
if tools. contains ( . draw) {
594
594
let drawColorLayout = UICollectionViewFlowLayout ( )
595
- let drawColorItemWidth : CGFloat = 30
595
+ let drawColorItemWidth : CGFloat = 36
596
596
drawColorLayout. itemSize = CGSize ( width: drawColorItemWidth, height: drawColorItemWidth)
597
- drawColorLayout. minimumLineSpacing = 15
598
- drawColorLayout. minimumInteritemSpacing = 15
597
+ drawColorLayout. minimumLineSpacing = 0
598
+ drawColorLayout. minimumInteritemSpacing = 0
599
599
drawColorLayout. scrollDirection = . horizontal
600
600
let drawColorTopBottomInset = ( drawColViewH - drawColorItemWidth) / 2
601
601
drawColorLayout. sectionInset = UIEdgeInsets ( top: drawColorTopBottomInset, left: 0 , bottom: drawColorTopBottomInset, right: 0 )
@@ -605,7 +605,6 @@ open class ZLEditImageViewController: UIViewController {
605
605
drawCV. delegate = self
606
606
drawCV. dataSource = self
607
607
drawCV. isHidden = true
608
- drawCV. showsHorizontalScrollIndicator = false
609
608
bottomShadowView. addSubview ( drawCV)
610
609
611
610
ZLDrawColorCell . zl. register ( drawCV)
@@ -621,17 +620,17 @@ open class ZLEditImageViewController: UIViewController {
621
620
}
622
621
623
622
let filterLayout = UICollectionViewFlowLayout ( )
624
- filterLayout. itemSize = CGSize ( width: filterColViewH - 20 , height: filterColViewH)
623
+ filterLayout. itemSize = CGSize ( width: filterColViewH - 30 , height: filterColViewH - 10 )
625
624
filterLayout. minimumLineSpacing = 15
626
625
filterLayout. minimumInteritemSpacing = 15
627
626
filterLayout. scrollDirection = . horizontal
627
+ filterLayout. sectionInset = UIEdgeInsets ( top: 0 , left: 0 , bottom: 10 , right: 0 )
628
628
629
629
let filterCV = UICollectionView ( frame: . zero, collectionViewLayout: filterLayout)
630
630
filterCV. backgroundColor = . clear
631
631
filterCV. delegate = self
632
632
filterCV. dataSource = self
633
633
filterCV. isHidden = true
634
- filterCV. showsHorizontalScrollIndicator = false
635
634
bottomShadowView. addSubview ( filterCV)
636
635
637
636
ZLFilterImageCell . zl. register ( filterCV)
@@ -677,8 +676,8 @@ open class ZLEditImageViewController: UIViewController {
677
676
bottomShadowView. addSubview ( revokeBtn)
678
677
if canRedo {
679
678
let btn = UIButton ( type: . custom)
680
- btn. setImage ( getImage ( " zl_redo_disable " ) , for: . disabled)
681
- btn. setImage ( getImage ( " zl_redo " ) , for: . normal)
679
+ btn. setImage ( . zl . getImage ( " zl_redo_disable " ) , for: . disabled)
680
+ btn. setImage ( . zl . getImage ( " zl_redo " ) , for: . normal)
682
681
btn. adjustsImageWhenHighlighted = false
683
682
btn. isEnabled = false
684
683
btn. isHidden = true
@@ -734,9 +733,9 @@ open class ZLEditImageViewController: UIViewController {
734
733
}
735
734
736
735
ZLImageEditorConfiguration . default ( ) . fontChooserContainerView? . selectFontBlock = { [ weak self] font in
737
- self ? . showInputTextVC ( font: font) { [ weak self] text, font, textColor , bgColor in
738
- self ? . addTextStickersView ( text, textColor: textColor, font: font, bgColor : bgColor )
739
- }
736
+ self ? . showInputTextVC ( font: font, completion : { [ weak self] text, textColor , font, image , style in
737
+ self ? . addTextStickersView ( text, textColor: textColor, font: font, image : image , style : style )
738
+ } )
740
739
}
741
740
}
742
741
@@ -840,8 +839,8 @@ open class ZLEditImageViewController: UIViewController {
840
839
setToolView ( show: false )
841
840
fontChooserContainerIsHidden = false
842
841
} else {
843
- showInputTextVC { [ weak self] text, _ , textColor , bgColor in
844
- self ? . addTextStickersView ( text, textColor: textColor, bgColor : bgColor )
842
+ showInputTextVC { [ weak self] text, textColor , font , image , style in
843
+ self ? . addTextStickersView ( text, textColor: textColor, font : font , image : image , style : style )
845
844
}
846
845
}
847
846
}
@@ -919,7 +918,7 @@ open class ZLEditImageViewController: UIViewController {
919
918
var textStickers : [ ( ZLTextStickerState , Int ) ] = [ ]
920
919
var imageStickers : [ ( ZLImageStickerState , Int ) ] = [ ]
921
920
for (index, view) in stickersContainer. subviews. enumerated ( ) {
922
- if let ts = view as? ZLTextStickerView , let _ = ts. label . text {
921
+ if let ts = view as? ZLTextStickerView , ! ts. text. isEmpty {
923
922
textStickers. append ( ( ts. state, index) )
924
923
} else if let ts = view as? ZLImageStickerView {
925
924
imageStickers. append ( ( ts. state, index) )
@@ -1177,7 +1176,7 @@ open class ZLEditImageViewController: UIViewController {
1177
1176
toolViewStateTimer = nil
1178
1177
}
1179
1178
1180
- func showInputTextVC( _ text: String ? = nil , textColor: UIColor ? = nil , font: UIFont ? = nil , bgColor : UIColor ? = nil , completion: @escaping ( String , UIFont , UIColor , UIColor ) -> Void ) {
1179
+ func showInputTextVC( _ text: String ? = nil , textColor: UIColor ? = nil , font: UIFont ? = nil , style : ZLInputTextStyle = . normal , completion: @escaping ( String , UIColor , UIFont , UIImage ? , ZLInputTextStyle ) -> Void ) {
1181
1180
var bgImage : UIImage ?
1182
1181
autoreleasepool {
1183
1182
// Calculate image displayed frame on the screen.
@@ -1196,10 +1195,10 @@ open class ZLEditImageViewController: UIViewController {
1196
1195
. zl. clipImage ( angle: 0 , editRect: r, isCircle: isCircle)
1197
1196
}
1198
1197
1199
- let vc = ZLInputTextViewController ( image: bgImage, text: text, font: font, textColor: textColor, bgColor : bgColor )
1198
+ let vc = ZLInputTextViewController ( image: bgImage, text: text, font: font, textColor: textColor, style : style )
1200
1199
1201
- vc. endInput = { text, font, textColor , bgColor in
1202
- completion ( text, font, textColor , bgColor )
1200
+ vc. endInput = { text, textColor , font, image , style in
1201
+ completion ( text, textColor , font, image , style )
1203
1202
}
1204
1203
1205
1204
vc. modalPresentationStyle = . fullScreen
@@ -1234,13 +1233,14 @@ open class ZLEditImageViewController: UIViewController {
1234
1233
}
1235
1234
1236
1235
/// Add text sticker
1237
- func addTextStickersView( _ text: String , textColor: UIColor , font: UIFont ? = nil , bgColor: UIColor ) {
1238
- guard !text. isEmpty else { return }
1236
+ func addTextStickersView( _ text: String , textColor: UIColor , font: UIFont , image: UIImage ? , style: ZLInputTextStyle ) {
1237
+ guard !text. isEmpty, let image = image else { return }
1238
+
1239
1239
let scale = mainScrollView. zoomScale
1240
- let size = ZLTextStickerView . calculateSize ( text : text , width : view . frame . width , font : font )
1240
+ let size = ZLTextStickerView . calculateSize ( image : image )
1241
1241
let originFrame = getStickerOriginFrame ( size)
1242
1242
1243
- let textSticker = ZLTextStickerView ( text: text, textColor: textColor, font: font, bgColor : bgColor , originScale: 1 / scale, originAngle: - angle, originFrame: originFrame)
1243
+ let textSticker = ZLTextStickerView ( text: text, textColor: textColor, font: font, style : style , image : image , originScale: 1 / scale, originAngle: - angle, originFrame: originFrame)
1244
1244
stickersContainer. addSubview ( textSticker)
1245
1245
textSticker. frame = originFrame
1246
1246
@@ -1692,22 +1692,23 @@ extension ZLEditImageViewController: ZLStickerViewDelegate {
1692
1692
}
1693
1693
1694
1694
func sticker( _ textSticker: ZLTextStickerView , editText text: String ) {
1695
- showInputTextVC ( text, textColor: textSticker. textColor, font: textSticker. textFont, bgColor: textSticker. bgColor) { [ weak self] text, font, textColor, bgColor in
1696
- guard let `self` = self else { return }
1697
- if text. isEmpty {
1695
+ showInputTextVC ( text, textColor: textSticker. textColor, font: textSticker. font, style: textSticker. style) { [ weak self] text, textColor, font, image, style in
1696
+ guard let image = image, !text. isEmpty else {
1698
1697
textSticker. moveToAshbin ( )
1699
- } else {
1700
- textSticker. startTimer ( )
1701
- guard textSticker. text != text || textSticker. textColor != textColor || textSticker. bgColor != bgColor else {
1702
- return
1703
- }
1704
- textSticker. text = text
1705
- textSticker. textColor = textColor
1706
- textSticker. bgColor = bgColor
1707
- textSticker. textFont = font
1708
- let newSize = ZLTextStickerView . calculateSize ( text: text, width: self . view. frame. width, font: font)
1709
- textSticker. changeSize ( to: newSize)
1698
+ return
1699
+ }
1700
+
1701
+ textSticker. startTimer ( )
1702
+ guard textSticker. text != text || textSticker. textColor != textColor || textSticker. style != style || textSticker. font != font else {
1703
+ return
1710
1704
}
1705
+ textSticker. text = text
1706
+ textSticker. textColor = textColor
1707
+ textSticker. style = style
1708
+ textSticker. image = image
1709
+ textSticker. font = font
1710
+ let newSize = ZLTextStickerView . calculateSize ( image: image)
1711
+ textSticker. changeSize ( to: newSize)
1711
1712
}
1712
1713
}
1713
1714
}
0 commit comments