Skip to content

Commit 4c91afe

Browse files
authored
Merge pull request #1 from native-mobile-app-developers/2.0
2.0
2 parents e6d92f5 + fc7b0a2 commit 4c91afe

File tree

9 files changed

+210
-75
lines changed

9 files changed

+210
-75
lines changed

Example/Pods/Target Support Files/Pods-SwiftStickerView_Example/Pods-SwiftStickerView_Example-Info.plist

+20-20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example/Pods/Target Support Files/Pods-SwiftStickerView_Tests/Pods-SwiftStickerView_Tests-Info.plist

+20-20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example/Pods/Target Support Files/SwiftStickerView/SwiftStickerView-Info.plist

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example/SwiftStickerView.xcodeproj/project.pbxproj

+6
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,12 @@
212212
TargetAttributes = {
213213
607FACCF1AFB9204008FA782 = {
214214
CreatedOnToolsVersion = 6.3.1;
215+
DevelopmentTeam = 4K9P34469L;
215216
LastSwiftMigration = 0900;
216217
};
217218
607FACE41AFB9204008FA782 = {
218219
CreatedOnToolsVersion = 6.3.1;
220+
DevelopmentTeam = 4K9P34469L;
219221
LastSwiftMigration = 0900;
220222
TestTargetID = 607FACCF1AFB9204008FA782;
221223
};
@@ -478,6 +480,7 @@
478480
baseConfigurationReference = AE402CC2380DD326BC90FB11 /* Pods-SwiftStickerView_Example.debug.xcconfig */;
479481
buildSettings = {
480482
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
483+
DEVELOPMENT_TEAM = 4K9P34469L;
481484
INFOPLIST_FILE = SwiftStickerView/Info.plist;
482485
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
483486
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
@@ -494,6 +497,7 @@
494497
baseConfigurationReference = D188173DBC5DE8D6DCA34D61 /* Pods-SwiftStickerView_Example.release.xcconfig */;
495498
buildSettings = {
496499
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
500+
DEVELOPMENT_TEAM = 4K9P34469L;
497501
INFOPLIST_FILE = SwiftStickerView/Info.plist;
498502
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
499503
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
@@ -509,6 +513,7 @@
509513
isa = XCBuildConfiguration;
510514
baseConfigurationReference = 0F750105565346444E0A2BAC /* Pods-SwiftStickerView_Tests.debug.xcconfig */;
511515
buildSettings = {
516+
DEVELOPMENT_TEAM = 4K9P34469L;
512517
FRAMEWORK_SEARCH_PATHS = (
513518
"$(PLATFORM_DIR)/Developer/Library/Frameworks",
514519
"$(inherited)",
@@ -531,6 +536,7 @@
531536
isa = XCBuildConfiguration;
532537
baseConfigurationReference = 717F402D2DF22B6661819DA2 /* Pods-SwiftStickerView_Tests.release.xcconfig */;
533538
buildSettings = {
539+
DEVELOPMENT_TEAM = 4K9P34469L;
534540
FRAMEWORK_SEARCH_PATHS = (
535541
"$(PLATFORM_DIR)/Developer/Library/Frameworks",
536542
"$(inherited)",

Example/SwiftStickerView/Base.lproj/Main.storyboard

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16097" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="vXZ-lx-hvc">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17156" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="vXZ-lx-hvc">
33
<device id="retina4_7" orientation="portrait" appearance="light"/>
44
<dependencies>
5-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
5+
<deployment identifier="iOS"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17126"/>
67
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
78
</dependencies>
89
<scenes>
@@ -22,10 +23,18 @@
2223
<rect key="frame" x="45" y="600" width="37" height="37"/>
2324
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
2425
</imageView>
25-
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="square.fill" catalog="system" translatesAutoresizingMaskIntoConstraints="NO" id="mUA-qT-qBD">
26+
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="flip.horizontal.fill" catalog="system" translatesAutoresizingMaskIntoConstraints="NO" id="mUA-qT-qBD">
2627
<rect key="frame" x="96" y="600" width="37" height="37"/>
2728
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
2829
</imageView>
30+
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="AqM-pY-UEx">
31+
<rect key="frame" x="197" y="617" width="162" height="30"/>
32+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
33+
<state key="normal" title="Show Hide EditBoundry"/>
34+
<connections>
35+
<action selector="showHideEditView:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="j0b-Za-HaJ"/>
36+
</connections>
37+
</button>
2938
</subviews>
3039
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
3140
</view>
@@ -36,7 +45,7 @@
3645
</scene>
3746
</scenes>
3847
<resources>
48+
<image name="flip.horizontal.fill" catalog="system" width="128" height="112"/>
3949
<image name="gobackward" catalog="system" width="121" height="128"/>
40-
<image name="square.fill" catalog="system" width="128" height="114"/>
4150
</resources>
4251
</document>

Example/SwiftStickerView/ViewController.swift

+9-3
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,27 @@ import SwiftStickerView
1212
class ViewController: UIViewController {
1313

1414
var selectedStickerView:StickerView! = nil
15-
15+
var stickerView:StickerView!
16+
1617
override func viewDidLoad() {
1718
super.viewDidLoad()
1819
let configuration = Configuration()
1920
configuration.borderWidth = 2
20-
configuration.buttonSize = CGSize(width: 16, height: 16)
21+
// configuration.buttonSize = CGSize(width: 32, height: 16)
2122

2223
let testView = UIImageView(frame: CGRect.init(x: 0, y: 0, width: 150, height: 100))
2324
testView.backgroundColor = UIColor.red
2425
testView.image = UIImage(named: "image")
25-
let stickerView = StickerView.init(contentView: testView, configuration: configuration)
26+
stickerView = StickerView.init(contentView: testView, configuration: configuration)
2627
stickerView.center = self.view.center
2728
self.view.addSubview(stickerView)
29+
2830
// Do any additional setup after loading the view, typically from a nib.
2931
}
32+
33+
@IBAction func showHideEditView(_ sender: Any) {
34+
stickerView.showEditingHandlers = !stickerView.showEditingHandlers
35+
}
3036

3137
override func didReceiveMemoryWarning() {
3238
super.didReceiveMemoryWarning()

Source/Configuration.swift

+87-18
Original file line numberDiff line numberDiff line change
@@ -12,44 +12,113 @@ enum ButtonType {
1212
}
1313

1414
enum ButtonPosition{
15-
case top_left,bottom_right,bottom_left,midle_left,midle_bottom
15+
case top_left,bottom_right,bottom_left,midle_left,midle_bottom,top_right
1616
}
1717

18+
1819
struct Button {
1920
var buttonPosition:ButtonPosition!
2021
var buttonType:ButtonType!
21-
var image:UIImage!
22-
var tintColor:UIColor!
23-
var buttonSize:CGSize!
22+
var button:UIButton!
23+
var isOverrideSize:Bool!
24+
private let _defaultbutton:UIButton = {
25+
let button = UIButton()
26+
button.setImage(UIImage(systemName: "square.fill")!, for: .normal)
27+
button.frame.size = CGSize(width: 16, height: 16)
28+
return button
29+
}()
30+
2431
init(buttonPosition:ButtonPosition!,
25-
buttonType:ButtonType!,tintColor:UIColor = .black,
26-
image:UIImage = UIImage(systemName: "square.fill")!,buttonSize:CGSize? = nil) {
32+
buttonType:ButtonType!,
33+
button:UIButton? = nil,
34+
isOverrideSize:Bool = false
35+
) {
2736
self.buttonPosition = buttonPosition
2837
self.buttonType = buttonType
29-
self.image = image
30-
self.tintColor = tintColor
31-
self.buttonSize = buttonSize
38+
39+
self.button = button ?? _defaultbutton
40+
self.isOverrideSize = isOverrideSize
3241
}
3342
}
3443

3544
open class Configuration {
3645

37-
public init(){}
38-
39-
var activeButtons:[Button]! = [Button(buttonPosition: .top_left, buttonType: .remove,image: UIImage(systemName: "trash")!),
40-
Button(buttonPosition: .bottom_right, buttonType: .scale,image: UIImage(systemName: "arrow.up.left.and.arrow.down.right")!),
41-
Button(buttonPosition: .bottom_left, buttonType: .rotate,image: UIImage(systemName: "gobackward")!),
42-
Button(buttonPosition: .midle_left, buttonType: .stretch_width,image: UIImage(systemName: "square.fill")!),
43-
Button(buttonPosition: .midle_bottom, buttonType: .stretch_height,image: UIImage(systemName: "square.fill")!)
44-
]
46+
var activeButtons:[Button]! = []
4547
var minimumSize:CGFloat! = 16 * 4
4648
public var insetMarging:CGFloat! = 16
4749
public var boarderColor:UIColor! = .darkGray
4850
public var borderWidth:CGFloat! = 2
49-
public var buttonSize:CGSize! = CGSize(width: 16, height: 16) {
51+
public var buttonSize:CGSize! = CGSize(width: 28, height: 28) {
5052
didSet{
5153
minimumSize = buttonSize.width * 4
5254
}
5355
}
5456

57+
private lazy var _trashButton:UIButton = {
58+
let button = UIButton()
59+
button.setImage(UIImage(systemName: "trash")!, for: .normal)
60+
button.frame.size = CGSize(width: 16, height: 16)
61+
buttonDecorator(button)
62+
return button
63+
}()
64+
private lazy var _scaleButton:UIButton = {
65+
let button = UIButton()
66+
button.setImage(UIImage(systemName: "arrow.up.left.and.arrow.down.right")!, for: .normal)
67+
button.frame.size = CGSize(width: 16, height: 16)
68+
buttonDecorator(button)
69+
return button
70+
}()
71+
72+
private lazy var _rotateButton:UIButton = {
73+
let button = UIButton()
74+
button.setImage(UIImage(systemName: "gobackward")!, for: .normal)
75+
button.frame.size = CGSize(width: 16, height: 16)
76+
buttonDecorator(button)
77+
return button
78+
}()
79+
80+
private lazy var _stretchWidthButton:UIButton = {
81+
let button = UIButton()
82+
button.setImage(UIImage(systemName: "square.fill")!, for: .normal)
83+
button.frame.size = CGSize(width: 16, height: 16)
84+
buttonDecorator(button)
85+
return button
86+
}()
87+
88+
private lazy var _stretchHeightButton:UIButton = {
89+
let button = UIButton()
90+
button.setImage(UIImage(systemName: "square.fill")!, for: .normal)
91+
button.frame.size = CGSize(width: 16, height: 16)
92+
buttonDecorator(button)
93+
return button
94+
}()
95+
private lazy var _flipImageButton:UIButton = {
96+
let button = UIButton()
97+
button.setImage(UIImage(systemName: "flip.horizontal.fill")!, for: .normal)
98+
button.frame.size = CGSize(width: 16, height: 16)
99+
buttonDecorator(button)
100+
return button
101+
}()
102+
103+
104+
private func buttonDecorator(_ button:UIButton){
105+
button.layer.shadowColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.25).cgColor
106+
button.layer.shadowOffset = CGSize(width: 0.0, height: 0.0)
107+
button.layer.shadowOpacity = 1.0
108+
button.layer.shadowRadius = 4.0
109+
button.layer.masksToBounds = false
110+
button.layer.cornerRadius = buttonSize.width/2
111+
button.backgroundColor = .white
112+
}
113+
114+
public init(){
115+
activeButtons = [Button(buttonPosition: .top_left, buttonType: .remove,button: _trashButton),
116+
Button(buttonPosition: .bottom_right, buttonType: .scale,button: _scaleButton),
117+
Button(buttonPosition: .bottom_left, buttonType: .rotate,button: _rotateButton),
118+
Button(buttonPosition: .midle_left, buttonType: .stretch_width,button: _stretchWidthButton),
119+
Button(buttonPosition: .midle_bottom, buttonType: .stretch_height,button: _stretchHeightButton),Button(buttonPosition: .top_right, buttonType: .flip,button: _flipImageButton)]
120+
}
121+
122+
123+
55124
}

0 commit comments

Comments
 (0)