Skip to content

Commit 03b42f6

Browse files
authored
Merge pull request #15 from mono0926/allow-empty-title
Allow empty title
2 parents c190c99 + 5b826b1 commit 03b42f6

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

Example/Base.lproj/Main.storyboard

+15-8
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@
2424
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
2525
</imageView>
2626
<visualEffectView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="hfa-GM-Q6d">
27-
<rect key="frame" x="0.0" y="0.0" width="113" height="270"/>
27+
<rect key="frame" x="0.0" y="0.0" width="113" height="300"/>
2828
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" id="BDZ-hc-dGd">
29-
<rect key="frame" x="0.0" y="0.0" width="113" height="270"/>
29+
<rect key="frame" x="0.0" y="0.0" width="113" height="300"/>
3030
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
3131
<subviews>
3232
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="1Qd-4G-b8f">
33-
<rect key="frame" x="0.0" y="0.0" width="113" height="270"/>
33+
<rect key="frame" x="0.0" y="0.0" width="113" height="300"/>
3434
<subviews>
3535
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="VXq-6g-Fy7">
3636
<rect key="frame" x="0.0" y="0.0" width="113" height="30"/>
@@ -60,36 +60,43 @@
6060
<action selector="emptyMessageDidTap:" destination="BYZ-38-t0r" eventType="touchUpInside" id="5aC-RM-lb4"/>
6161
</connections>
6262
</button>
63-
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="0Jg-tM-afe">
63+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="di4-WJ-BNV">
6464
<rect key="frame" x="0.0" y="120" width="113" height="30"/>
65+
<state key="normal" title="Empty Title"/>
66+
<connections>
67+
<action selector="emptyTitleDidTap:" destination="BYZ-38-t0r" eventType="touchUpInside" id="hXU-gJ-aRs"/>
68+
</connections>
69+
</button>
70+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="0Jg-tM-afe">
71+
<rect key="frame" x="0.0" y="150" width="113" height="30"/>
6572
<state key="normal" title="Emoji"/>
6673
<connections>
6774
<action selector="emojiDidTap:" destination="BYZ-38-t0r" eventType="touchUpInside" id="BgE-JD-noM"/>
6875
</connections>
6976
</button>
7077
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="qxP-p0-yZR">
71-
<rect key="frame" x="0.0" y="150" width="113" height="30"/>
78+
<rect key="frame" x="0.0" y="180" width="113" height="30"/>
7279
<state key="normal" title="10 seconds"/>
7380
<connections>
7481
<action selector="longDidTap:" destination="BYZ-38-t0r" eventType="touchUpInside" id="jok-vX-ajz"/>
7582
</connections>
7683
</button>
7784
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="g9m-dr-Kab">
78-
<rect key="frame" x="0.0" y="180" width="113" height="30"/>
85+
<rect key="frame" x="0.0" y="210" width="113" height="30"/>
7986
<state key="normal" title="FadeIn"/>
8087
<connections>
8188
<action selector="fadeInDidTap:" destination="BYZ-38-t0r" eventType="touchUpInside" id="fPD-YX-U6c"/>
8289
</connections>
8390
</button>
8491
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="dIe-Qf-ugv">
85-
<rect key="frame" x="0.0" y="210" width="113" height="30"/>
92+
<rect key="frame" x="0.0" y="240" width="113" height="30"/>
8693
<state key="normal" title="Done Animation"/>
8794
<connections>
8895
<action selector="doneAnimatinDidTap:" destination="BYZ-38-t0r" eventType="touchUpInside" id="ivC-bu-MEk"/>
8996
</connections>
9097
</button>
9198
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="npQ-Jc-VDT">
92-
<rect key="frame" x="0.0" y="240" width="113" height="30"/>
99+
<rect key="frame" x="0.0" y="270" width="113" height="30"/>
93100
<state key="normal" title="Cross Animation"/>
94101
<connections>
95102
<action selector="crossAnimatinDidTap:" destination="BYZ-38-t0r" eventType="touchUpInside" id="EE1-qa-Iox"/>

Example/ViewController.swift

+5
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ class ViewController: UIViewController {
3333
title: "Empty Message 🗑",
3434
message: nil)
3535
}
36+
@IBAction func emptyTitleDidTap(_ sender: UIButton) {
37+
NativePopup.show(image: Preset.Feedback.good,
38+
title: nil,
39+
message: "Empty Title 🗑")
40+
}
3641
@IBAction func emojiDidTap(_ sender: UIButton) {
3742
NativePopup.show(image: Character("🐶"),
3843
title: "イッヌ",

NativePopup/NativePopup.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class NativePopup: UIView {
1616
private let imageContentView: UIView
1717

1818
public static func show(image: ImageConvertible,
19-
title: String,
19+
title: String?,
2020
message: String?,
2121
duration: TimeInterval = 1.5,
2222
initialEffectType: InitialEffectType = .fromBottom) {
@@ -31,7 +31,7 @@ public class NativePopup: UIView {
3131
}
3232

3333
private init(image: ImageConvertible,
34-
title: String,
34+
title: String?,
3535
message: String?) {
3636
effectView = UIVisualEffectView(effect: UIBlurEffect(style: .extraLight))
3737

@@ -93,7 +93,7 @@ public class NativePopup: UIView {
9393
imageContentView.centerXAnchor.constraint(equalTo: centerXAnchor).isActive = true
9494
imageContentView.bottomAnchor.constraint(equalTo: titleLabel.topAnchor, constant: -(17 + image.additionalMarginBottom)).isActive = true
9595

96-
let sideSpace: CGFloat = 8
96+
let sideSpace: CGFloat = 16
9797
titleLabel.leftAnchor.constraint(equalTo: leftAnchor, constant: sideSpace).isActive = true
9898
titleLabel.rightAnchor.constraint(equalTo: rightAnchor, constant: -sideSpace).isActive = true
9999

0 commit comments

Comments
 (0)