Git Product home page Git Product logo

ptpopupwebview's Introduction

PTPopupWebView

Version License Platform

PTPopupWebView is a simple and useful WebView for iOS, which can be popup and has many of the customized item. Pop

Requirement

iOS 8.0

Installation

PTPopupWebView is available through CocoaPods. To install it, simply add the following line to your Podfile:

use_frameworks!
pod "PTPopupWebView"

Usage

To use this library, there are two ways,

  1. Use PTPopupWebViewController, this is simple when use as modal popup.
  2. Directly use PTPopupWebView.

Details, see the Demo and the Class Reference.

Class Reference

Class Reference

Demo

To run the example project, clone the repo, and run pod install from the Example directory first.

Introduction

At first, to popup webpage is only code below.

let popupvc = PTPopupWebViewController()
popupvc.popupView.URL(string: "https://github.com/")
popupvc.show()

Popup Transition Style

Popup Appear/Disappear Style can be changed as below.

// Pop Style (default transition style. 1st parameter is animation duration, and 2nd is using spring animation flag.)
let popupvc = PTPopupWebViewController()
    .popupAppearStyle(.Slide(.Bottom, 0.4, true))
    .popupDisappearStyle(.Slide(.Bottom, 0.4, true))
// Spread Style (parameter is animation duration)
let popupvc = PTPopupWebViewController()
    .popupAppearStyle(.Spread(0.25))
    .popupDisappearStyle(.Spread(0.25))
// Slide Style (1st parameter is direction, 2nd is animation duration, and 3rd is using spring animation flag.)
let popupvc = PTPopupWebViewController()
    .popupAppearStyle(.Slide(.Bottom, 0.4, true))
    .popupDisappearStyle(.Slide(.Bottom, 0.4, true))
// Fade Style (parameter is animation duration)
let popupvc = PTPopupWebViewController()
    .popupAppearStyle(.Fade(0.25))
    .popupDisappearStyle(.Fade(0.25))
// Without Transition Style
let popupvc = PTPopupWebViewController()
    .popupAppearStyle(.None)
    .popupDisappearStyle(.None)
Pop Spread Slide
Pop Spread Slide
Fade None
Fade Introduction

Custom Action

Custom action button can do user defined action with PTPopupWebViewButton's handler property.

popupvc.popupView
    // add custom action button
    .addButton(
        PTPopupWebViewButton(type: .Custom)
            .title("custom"))
            .handler() {
                // write handler code here

                // this demo show alert view
                let alert:UIAlertController = UIAlertController(title: "Custom Action",message: popupvc.popupView.webView.title!,preferredStyle: UIAlertControllerStyle.Alert)
                alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil))
                popupvc.presentViewController(alert, animated: true, completion: nil)
            }
    // add close button
    .addButton(PTPopupWebViewButton(type: .Close).title("close"))
popupvc.show()
Custom Action
Custom Action

View Style

Details code reference to the source code of the demo application.

Title Style
Colored Title Hide Title
Colored Title Hide Title
Button Style
Colored Button Custom Image Button Hide Button
Colored Button Custom Image Button Hide Button
Other Style
FullScreen With Frame
FullScreen With Frame

Author

Takeshi Watanabe, [email protected]

License

PTPopupWebView is available under the MIT license. See the LICENSE file for more info.

ptpopupwebview's People

Contributors

pjocprac avatar tumiki0ituki avatar

Stargazers

 avatar houseme avatar  avatar Oleksandr Balabon avatar  avatar Zongyao Qu avatar Luis Carrasco avatar anyinfa avatar  avatar  avatar Mighel avatar ShadowParticle avatar  avatar  avatar Zen avatar Popeye Lau avatar  avatar lil hope avatar  avatar Nikolay Kirsh avatar E-Tiger Studio avatar Mustafa GÜNEŞ avatar Lee Dong In avatar Bruce Shum avatar  avatar Carlos Eugenio Torres avatar Savaş ADAR avatar Thomas Götzsche avatar Ryo Yoshida avatar  avatar SeongHo Hong avatar Henry Hardy avatar  avatar Emre YILMAZ avatar X.Y. Hu avatar drew.. avatar  avatar Tim Hazhyi avatar Hosein avatar  avatar Urayoán Miranda avatar Shaw Pin avatar Alex Nielsen avatar  avatar Omar Al tawashi avatar  avatar  avatar 晋先森 avatar Kateryna Sytnyk avatar Rufat Babayev avatar Daniel Botka avatar boby avatar Rafał Wójcik avatar Patrick Akoury avatar Arthur P. avatar Justin Kaufman avatar Sheldon avatar Nigel Holmes avatar Yakup AD avatar  avatar  avatar (Ken) Cong Bach avatar Donny Ho avatar Orion avatar LordOfTheRains avatar Dor avatar  avatar  avatar Mert avatar Mustafa Ozguner avatar Jhuang Dong Shuo avatar yuyf avatar Danilo Caetano avatar  avatar  avatar Azbuky avatar  avatar Viraj Patel avatar lin qin avatar Milind Shah avatar 葛文明 avatar Rafael da Silva Ferreira avatar Jason Crawford avatar Eric avatar Can Aksoy avatar Baoming Bai avatar David Yang, 杨志强 avatar  avatar Ma'moun Diraneyya avatar Musa Almatri avatar He, Yong(LEON) avatar Lincoln W Daniel avatar Danny Lin avatar feelnx avatar Harimoto avatar Manuel Escrig avatar  avatar Ali Ashoor avatar  avatar youliang avatar

Watchers

Eric avatar HoNooD avatar Milind Shah avatar  avatar  avatar  avatar Thomas Götzsche avatar Hoa Thiên Vũ avatar  avatar Urayoán Miranda avatar  avatar

ptpopupwebview's Issues

Not support local HTML string file.

Can not load the local HTML file.
`

        let pathString = Bundle.main.path(forResource: "licenses", ofType: "html")

        let popupvc = PTPopupWebViewController()

        popupvc.popupView.URL(string: pathString!)

        popupvc.show()

`

.LinkClose does not serve any function apart from closing the WebView

.LinkClose seems confusing as a button option. My first instinct was that it closed the popup and opened the link in Safari but essentially it is refreshing to that page and immediately closing the popup which seems fruitless.

I recommend changing this to provide functionality to open the link externally from the app or remove this option entirely.

Awesome library btw!!

Warning message: Result of call to 'URL' is unused

The library works perfectly, as I only get a warning message saying
Result of call to 'URL' is unused
for the function shown below:

open func URL(string urlString: String) -> Self {
URL(Foundation.URL(string: urlString))
return self
}

screen shot 2017-06-17 at 7 26 59 am

And also any place where I make the call to popup the webview giving it the specified URL.

xcode version: Version 8.3.2 (8E2002)

Thanks
Joseph

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.