Git Product home page Git Product logo

swiftoverlays's Introduction

Imgur

SwiftOverlays is a Swift GUI library for displaying various popups and notifications.

SwiftOverlays animated logo is kindly made by Crafted Pixels

Build Status Carthage compatible

Features

SwiftOverlays provides several ways to notify user:

  • Wait overlay: a simple overlay with activity indicator

Wait

  • Wait overlay with text

WaitWithText

  • Overlay with text only
  • Overlay with image and text (can be used with PPSwiftGifs to show custom animated GIF instead of UIActivityIndicatorView)
  • All of the above with blocking any user interaction
  • Notification on top of the status bar, similar to native iOS local/push notifications

Notification

Installation

Manual

Just clone and add SwiftOverlays.swift to your project.

Carthage

  • > Cartfile
  • nano Cartfile
  • put github "peterprokop/SwiftOverlays" ~> 5.0.1 into Cartfile
  • Save it: ctrl-x, y, enter
  • Run carthage update
  • Copy SwiftOverlays.framework from Carthage/Build/iOS to your project
  • Make sure that SwiftOverlays is added in Embedded Binaries section of your target (or else you will get dyld library not loaded referenced from ... reason image not found error)
  • Add import SwiftOverlays on top of your view controller's code

Cocoapods

  • Make sure that you use latest stable Cocoapods version: pod --version
  • If not, update it: sudo gem install cocoapods
  • pod init in you project root dir
  • nano Podfile, add:
pod 'SwiftOverlays', '~> 5.0.1'
use_frameworks! 
  • Save it: ctrl-x, y, enter
  • pod update
  • Open generated .xcworkspace
  • Don't forget to import SwiftOverlays: import SwiftOverlays!

Requirements

  • iOS 10.0+
  • Xcode 10.0+
  • Swift 4.2 (if you need older swift version, see swift-3.0 and others)

Usage

If you're using CocoaPods, import the library with import SwiftOverlays

You can use UIViewController convenience methods provided by library:

// In your view controller:

// Wait overlay
self.showWaitOverlay()

// Wait overlay with text
let text = "Please wait..."
self.showWaitOverlayWithText(text)

// Overlay with text only
let text = "This is a text-only overlay...\n...spanning several lines"
self.showTextOverlay(text)

// Remove everything
self.removeAllOverlays()

// Notification on top of the status bar
UIViewController.showOnTopOfStatusBar(annoyingNotificationView!, duration: 5)

// Block user interaction
SwiftOverlays.showBlockingWaitOverlayWithText("This is blocking overlay!")

// Don't forget to unblock!
SwiftOverlays.removeAllBlockingOverlays()

Using with UITableViewController/UICollectionViewController

You can't use SwiftOverlays convenience methods directly with UITableViewController - because its view is, well, an UITableView, and overlay will be scrolled along with it.

Instead I suggest using UIViewController instead of UITableViewController and adding UITableView as a subview. (the same applies to UICollectionViewController)

If for some reason you can't use UIViewController, you can do something like:

if let superview = self.view.superview {
  SwiftOverlays.showCenteredWaitOverlayWithText(superview, text: "Please wait...")
  SwiftOverlays.removeAllOverlaysFromView(superview)
}

(but in that case overlay will be added to the superview, and you should obviously do that only if superview is available - for example in viewDidAppear method of your controller.).

Contribution

You are welcome to fork and submit pull requests

Other Projects

  • StarryStars - iOS GUI library for displaying and editing ratings.
  • AlertyAlert - AlertyAlert is a nice and fluffy iOS alert library for all your alerty needs.

swiftoverlays's People

Contributors

apradanas avatar cdmoyer avatar dirkfabisch avatar fancytapsio avatar fiveze avatar jeystarratt avatar peterprokop avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

swiftoverlays's Issues

notification view presenting animation?

When you present a notification view, it doesn't animate in, it just appears, whereas when the notification view disappears, it moves up and fades out nicely.
Can you change the library so that when the notification appears, it appears at the top of the screen and moves down (like the native notification). Effectively the reverse of the disappearing animation.

Thanks

Swift3

Hey Peter, thanks for your library.
Do you know how to include the swift 3 branch in carthage?

I tried to put the following string in my cartfile:
github "peterprokop/SwiftOverlays" "swift-3.0"

But when I update I get the following error messages:
SwiftOverlays/SwiftOverlays/SwiftOverlays.swift:303:27: error: value of type 'CGRect' has no member 'offsetInPlace'
SwiftOverlays/SwiftOverlays.swift:310:27: error: value of type 'CGRect' has no member 'offsetInPlace'
SwiftOverlays/SwiftOverlays/SwiftOverlays.swift:415:58: error: cannot call value of non-function type 'UIColor'
SwiftOverlays.swift:418:70: error: cannot call value of non-function type 'UIScreen'
SwiftOverlays/SwiftOverlays.swift:490:42: error: cannot call value of non-function type 'UIApplication'

Thanks,
Francois.

Calling UIViewController.showOnTopOfStatusBar twice has strange effects

Hi there,

if you call
UIViewController.showOnTopOfStatusBar(view, duration: 1, animated: true)
and then call it again before the first notification disappeared, all further calls will show the notification twice.

Please see the following clip to get a better understanding:
ezgif com-video-to-gif

Is there a way to remove the old notification that is still visible below the new one?

Swift 2.0 Issue Using Renamed RectByOffsetting

Just tried porting over my project using the swift-2.0 branch and the compiler is complaining about line 207 in SwiftOverlays.swift:

screen shot 2015-09-02 at 2 51 48 pm

Not sure what the status is on the migration to 2.0, but I can fix this and submit a pull request. Thanks!

Test

This is a test

iPhone X display

On iPhone X, the notification view should be displayed a bit lower, otherwise it can't by fully seen.
Is there anyone having the same issue, or am i missing something here ? There's no one report about this issue, which seems strange to me.

swift-3.0 branch requires a higher minimum target than 8.1

These are the target configurations in my Podfile:
use_frameworks!
platform :ios, '8.1'

This is the line in my Podfile for SwiftOverlays:
pod 'SwiftOverlays', :git => 'https://github.com/peterprokop/SwiftOverlays', :branch => 'swift-3.0'

The Swift 2 version, which I was using until recently, worked with iOS 8.1, and this project's readme only says that it requires "iOS 7.0+ (8.0+ if you use Cocoapods)".
When I run pod install, it gives the following printout:
$ pod install
Analyzing dependencies
Pre-downloading: SwiftOverlays from https://github.com/peterprokop/SwiftOverlays, branch swift-3.0
[!] Unable to satisfy the following requirements:

Specs satisfying the SwiftOverlays (fromhttps://github.com/peterprokop/SwiftOverlays`, branch swift-3.0)` dependency were found, but they required a higher minimum deployment target.

Changing my podfile to require iOS 9.1 makes the pod install work, but my project would much rather support 8.1. Is there any fix for this? If not, the readme should probably be updated to reflect it.

Add width constraints to avoid cropped text

I use method SwiftOverlays.showBlockingWaitOverlayWithText("example. many words ...")

If the string argument contains a several sentences ( > 8-10 words) the width will be more than the width of the screen (iPhone 5s for e.g.)
So, we need width constraints.

If we have universal app, the solution below is not suitable.(because we need different strings for ipad(without \n) and iphone)

// Overlay with text only
let text = "This is a text-only overlay...\n...spanning several lines"
self.showTextOverlay(text)

Swift4

Will this be updated for Swift 4?

Consider adding Carthage support.

Hi,
I know SwiftOverlays ist just one file and an easy drop-in installation at that.
But since you're providing a Cocoapods Podfile why not consider to also support Carthage.
Carthage is really getting traction for Swift frameworks and it would be great to have SwiftOverlays on it.

Cheers,

Add a light mode

It would be nice if we could have a light mode, just like in the Settings app when you upload a new profile picture for you iCloud account !

updateOverlayText not working with blockingWaitOverlay

This code is not working :
let soView = SwiftOverlays.showBlockingWaitOverlayWithText("Original text")
SwiftOverlays.updateOverlayText(soView, text: "Updated text")

I think it's because a blockingWaitOverlay is containing two levels of containerViewTag before having the label. At this opposite of a traditional SwiftOverlay view.

To fix that I've temporary updated your updateOverlayText function this way, but I guess there's a more proper way to do it (or maybe i've missed another official trick to do it)

open class func updateOverlayText(_ parentView: UIView, text: String) {
    if let overlay = parentView.viewWithTag(containerViewTag) {
        for subview in overlay.subviews {
            if let label = subview as? UILabel {
                label.text = text as String
                break
            }
            
            if let subOverlay = subview.viewWithTag(containerViewTag) {
                
                for subSubView in subOverlay.subviews {
                    if let subLabel = subSubView as? UILabel {
                        subLabel.text = text as String
                        break
                    }
                }
                
            }
            
        }
    }
}

Swift Overlays 4 and Objective-C

Right now it seems it's not possible to use SwiftOverlays 4.0.0 in Objective-C code. I believe this is because the public methods in Swift need to be marked with @objc in order to be made available to the Objective-C code (@objc inference was deprecated). Am I right or it's just me messing something? :)
Is this a natural evolution and we need to use v3.0.0 of Swift Overlays if we want to continue using it in Objective-C?
Thanks!

deployment_target

Hi,

In one of your last commit you said: "change deployment to 8.0"
But on SwiftOverlays.podspec there is ios.deployment_target = '9.0'.

It is normal ? Because I can't install with ios deployment target 8.0.
Error of commit or error of podspec ?

Thank in advance.

Text vertical alignment

When you use methods which allow to use a custom image, if the image is higher than the text the latter is aligned at the top of the overlay. It would be probably nicer to let the user choose the alignment or, at least, forcing a vertical alignment in the middle of the overlay.

Swift 3 warning

Got this warning, using 3.0.0 version

SwiftOverlays/SwiftOverlays/SwiftOverlays.swift:93:5: @discardableResult declared on a function returning Void is unnecessary

Carthage, Xcode8 and Swift3 problem.

Hello,
when I try to use SwiftOverlays library with using Carthage, Xcode8 and Swift 3 I always get following error during building stage:

`*** Building scheme "SwiftOverlays" in Example.xcodeproj
2016-09-21 07:58:49.468 xcodebuild[82596:470516] [MT] PluginLoading: Required plug-in compatibility UUID 8A66E736-A720-4B3C-92F1-33D9962C69DF for plug-in at path '/Library/Application Support/Developer/Shared/Xcode/Plug-ins/VVDocumenter-Xcode.xcplugin' not present in DVTPlugInCompatibilityUUIDs
2016-09-21 07:58:49.469 xcodebuild[82596:470516] [MT] PluginLoading: Required plug-in compatibility UUID 8A66E736-A720-4B3C-92F1-33D9962C69DF for plug-in at path '
/Library/Application Support/Developer/Shared/Xcode/Plug-ins/UncrustifyPlugin.xcplugin' not present in DVTPlugInCompatibilityUUIDs
2016-09-21 07:58:49.470 xcodebuild[82596:470516] [MT] PluginLoading: Required plug-in compatibility UUID 8A66E736-A720-4B3C-92F1-33D9962C69DF for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/Alcatraz.xcplugin' not present in DVTPlugInCompatibilityUUIDs
** BUILD FAILED **

The following build commands failed:
CompileSwift normal arm64 /Users/admin/Documents/Projects/_//Network/Carthage/Checkouts/SwiftOverlays/SwiftOverlays/SwiftOverlays.swift
CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler
(2 failures)
/Users/admin/Documents/Projects/**
/_/Network/Carthage/Checkouts/SwiftOverlays/SwiftOverlays/SwiftOverlays.swift:245:42: error: cannot call value of non-function type 'UIApplication'
/Users/admin/Documents/Projects/
/**/Network/Carthage/Checkouts/SwiftOverlays/SwiftOverlays/SwiftOverlays.swift:303:27: error: value of type 'CGRect' has no member 'offsetInPlace'
/Users/admin/Documents/Projects/_//Network/Carthage/Checkouts/SwiftOverlays/SwiftOverlays/SwiftOverlays.swift:310:27: error: value of type 'CGRect' has no member 'offsetInPlace'
/Users/admin/Documents/Projects/**
/_/Network/Carthage/Checkouts/SwiftOverlays/SwiftOverlays/SwiftOverlays.swift:415:58: error: cannot call value of non-function type 'UIColor'
/Users/admin/Documents/Projects/
/**/Network/Carthage/Checkouts/SwiftOverlays/SwiftOverlays/SwiftOverlays.swift:418:70: error: cannot call value of non-function type 'UIScreen'
/Users/admin/Documents/Projects/_//Network/Carthage/Checkouts/SwiftOverlays/SwiftOverlays/SwiftOverlays.swift:490:42: error: cannot call value of non-function type 'UIApplication'
A shell task (/usr/bin/xcrun xcodebuild -project /Users/admin/Documents/Projects/**
/**_/Network/Carthage/Checkouts/SwiftOverlays/Example/Example.xcodeproj -scheme SwiftOverlays -configuration Release -sdk iphoneos ONLY_ACTIVE_ARCH=NO BITCODE_GENERATION_MODE=bitcode CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES clean build) failed with exit code 65:
2016-09-21 07:58:49.468 xcodebuild[82596:470516] [MT] PluginLoading: Required plug-in compatibility UUID 8A66E736-A720-4B3C-92F1-33D9962C69DF for plug-in at path '/Library/Application Support/Developer/Shared/Xcode/Plug-ins/VVDocumenter-Xcode.xcplugin' not present in DVTPlugInCompatibilityUUIDs
2016-09-21 07:58:49.469 xcodebuild[82596:470516] [MT] PluginLoading: Required plug-in compatibility UUID 8A66E736-A720-4B3C-92F1-33D9962C69DF for plug-in at path '
/Library/Application Support/Developer/Shared/Xcode/Plug-ins/UncrustifyPlugin.xcplugin' not present in DVTPlugInCompatibilityUUIDs
2016-09-21 07:58:49.470 xcodebuild[82596:470516] [MT] PluginLoading: Required plug-in compatibility UUID 8A66E736-A720-4B3C-92F1-33D9962C69DF for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/Alcatraz.xcplugin' not present in DVTPlugInCompatibilityUUIDs
** BUILD FAILED **

The following build commands failed:
CompileSwift normal arm64 /Users/admin/Documents/Projects/_/_/Carthage/Checkouts/SwiftOverlays/SwiftOverlays/SwiftOverlays.swift
CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler
(2 failures)
`
My cartfile content is

github "peterprokop/SwiftOverlays" "swift-3.0"

Could you please look at that?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.