Skip to content

Commit

Permalink
Merge pull request #15 from mono0926/allow-empty-title
Browse files Browse the repository at this point in the history
Allow empty title
  • Loading branch information
mono0926 authored May 30, 2017
2 parents c190c99 + 5b826b1 commit 03b42f6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
23 changes: 15 additions & 8 deletions Example/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
</imageView>
<visualEffectView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="hfa-GM-Q6d">
<rect key="frame" x="0.0" y="0.0" width="113" height="270"/>
<rect key="frame" x="0.0" y="0.0" width="113" height="300"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" id="BDZ-hc-dGd">
<rect key="frame" x="0.0" y="0.0" width="113" height="270"/>
<rect key="frame" x="0.0" y="0.0" width="113" height="300"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="1Qd-4G-b8f">
<rect key="frame" x="0.0" y="0.0" width="113" height="270"/>
<rect key="frame" x="0.0" y="0.0" width="113" height="300"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="VXq-6g-Fy7">
<rect key="frame" x="0.0" y="0.0" width="113" height="30"/>
Expand Down Expand Up @@ -60,36 +60,43 @@
<action selector="emptyMessageDidTap:" destination="BYZ-38-t0r" eventType="touchUpInside" id="5aC-RM-lb4"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="0Jg-tM-afe">
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="di4-WJ-BNV">
<rect key="frame" x="0.0" y="120" width="113" height="30"/>
<state key="normal" title="Empty Title"/>
<connections>
<action selector="emptyTitleDidTap:" destination="BYZ-38-t0r" eventType="touchUpInside" id="hXU-gJ-aRs"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="0Jg-tM-afe">
<rect key="frame" x="0.0" y="150" width="113" height="30"/>
<state key="normal" title="Emoji"/>
<connections>
<action selector="emojiDidTap:" destination="BYZ-38-t0r" eventType="touchUpInside" id="BgE-JD-noM"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="qxP-p0-yZR">
<rect key="frame" x="0.0" y="150" width="113" height="30"/>
<rect key="frame" x="0.0" y="180" width="113" height="30"/>
<state key="normal" title="10 seconds"/>
<connections>
<action selector="longDidTap:" destination="BYZ-38-t0r" eventType="touchUpInside" id="jok-vX-ajz"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="g9m-dr-Kab">
<rect key="frame" x="0.0" y="180" width="113" height="30"/>
<rect key="frame" x="0.0" y="210" width="113" height="30"/>
<state key="normal" title="FadeIn"/>
<connections>
<action selector="fadeInDidTap:" destination="BYZ-38-t0r" eventType="touchUpInside" id="fPD-YX-U6c"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="dIe-Qf-ugv">
<rect key="frame" x="0.0" y="210" width="113" height="30"/>
<rect key="frame" x="0.0" y="240" width="113" height="30"/>
<state key="normal" title="Done Animation"/>
<connections>
<action selector="doneAnimatinDidTap:" destination="BYZ-38-t0r" eventType="touchUpInside" id="ivC-bu-MEk"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="npQ-Jc-VDT">
<rect key="frame" x="0.0" y="240" width="113" height="30"/>
<rect key="frame" x="0.0" y="270" width="113" height="30"/>
<state key="normal" title="Cross Animation"/>
<connections>
<action selector="crossAnimatinDidTap:" destination="BYZ-38-t0r" eventType="touchUpInside" id="EE1-qa-Iox"/>
Expand Down
5 changes: 5 additions & 0 deletions Example/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ class ViewController: UIViewController {
title: "Empty Message 🗑",
message: nil)
}
@IBAction func emptyTitleDidTap(_ sender: UIButton) {
NativePopup.show(image: Preset.Feedback.good,
title: nil,
message: "Empty Title 🗑")
}
@IBAction func emojiDidTap(_ sender: UIButton) {
NativePopup.show(image: Character("🐶"),
title: "イッヌ",
Expand Down
6 changes: 3 additions & 3 deletions NativePopup/NativePopup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class NativePopup: UIView {
private let imageContentView: UIView

public static func show(image: ImageConvertible,
title: String,
title: String?,
message: String?,
duration: TimeInterval = 1.5,
initialEffectType: InitialEffectType = .fromBottom) {
Expand All @@ -31,7 +31,7 @@ public class NativePopup: UIView {
}

private init(image: ImageConvertible,
title: String,
title: String?,
message: String?) {
effectView = UIVisualEffectView(effect: UIBlurEffect(style: .extraLight))

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

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

Expand Down

0 comments on commit 03b42f6

Please sign in to comment.