- December 17, 2024
- Mins Read
SwiftWebVC is a simple inline browser for your Swift iOS app.
SwiftWebVC features:
setNetworkActivityIndicatorVisible
pod ‘SwiftWebVC’
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
You can install Carthage with Homebrew using the following command:
$ brew update
$ brew install carthage
To integrate SwiftWebVC into your Xcode project using Carthage, specify it in your Cartfile
:
github “meismyles/SwiftWebVC”
Run carthage update
to build the framework and drag the built SwiftWebVC.framework
into your Xcode project.
SwiftWebVC/
folder into your project.
Just like any UIViewController, SwiftWebVC can be pushed into a UINavigationController stack:
let webVC = SwiftWebVC(urlString: “http://google.com”)
self.navigationController?.pushViewController(webVC, animated: true)
It can be presented modally using SwiftModalWebVC
:
let webVC = SwiftModalWebVC(urlString: “http://google.com”)
self.present(webVC, animated: true, completion: nil)
The share button can be disabled by passing a flag in to the constructor to specify this:
let webVC = SwiftWebVC(urlString: “http://google.com”, sharingEnabled: false)
The same principal applies for the modal implementation also:
let webVC = SwiftModalWebVC(urlString: “http://google.com”, sharingEnabled: false)
Themes may be chosen for the modal implementation. The default theme is Light-Blue
. Other modal themes Light-Black
and Dark
may be chosen using one of the following instead:
let webVC = SwiftModalWebVC(urlString: “http://google.com”, theme: .lightBlack)
let webVC = SwiftModalWebVC(urlString: “http://google.com”, theme: .dark)
SwiftWebVC also includes a delegate protocol that allows you to implement didStartLoading
and didFinishLoading
functions to determine when loading starts and finishes.
Note: This is currently only implemented for SwiftWebVC
, not SwiftModalWebVC
.
To implement this, after declaring your instance of SwiftWebVC
, set it’s delegate and implement the callback functions. For example:
Inititalisation
let webVC = SwiftWebVC(urlString: “https://www.google.com”)
webVC.delegate = self
self.navigationController?.pushViewController(webVC, animated: true)
Delegate Implementation
extension ViewController: SwiftWebVCDelegate {
func didStartLoading() {
print(“Started loading.”)
}
func didFinishLoading(success: Bool) {
print(“Finished loading. Success: \(success).”)
}
}
Starting in iOS 6 Apple uses UIActivity
to let you show additional sharing methods in share sheets. SwiftWebVC
comes with “Open in Safari” and “Open in Chrome” activities. You can easily add your own activity by subclassing SwiftWebVCActivity
which takes care of a few things automatically for you. Have a look at the Safari and Chrome activities for implementation examples.Typed
A vertical stackview which takes subviews with different widths and adds them to it's rows with paddings, spacings etc.
AudioManager is a Swift package that provides a modular and easy-to-use interface for implementing audio feedback in your applications. It ...