A UIControl subclass that makes it easy to create empty states.

Related tags

UI AZEmptyState
Overview

AZEmptyState

Making empty state simple.

Screenshots

Installation

Cocoa Pods:

pod 'AZEmptyState'

Manual:

Simply drag and drop the Sources folder to your project.

Usage:

Using Interface Builder:

Programmatically:

//init var
emptyStateView = AZEmptyStateView()

//customize
emptyStateView.image = #imageLiteral(resourceName: "thinking")
emptyStateView.message = "Something went wrong..."
emptyStateView.buttonText = "Try Again"
emptyStateView.addTarget(self, action: #selector(tryAgain), for: .touchUpInside)

//add subview
view.addSubview(emptyStateView)

//add autolayout
emptyStateView.translatesAutoresizingMaskIntoConstraints = false
emptyStateView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
emptyStateView.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true
emptyStateView.widthAnchor.constraint(equalTo: view.widthAnchor, multiplier: 0.6).isActive = true
emptyStateView.heightAnchor.constraint(equalTo: view.heightAnchor, multiplier: 0.55).isActive = true

Sub Classing

Here is an example of sub-classing:

@IBDesignable
class MyEmptyStateView: AZEmptyStateView{

    //Use image with content mode of `scale aspect fit`
    override func setupImage() -> UIImageView {
        let imageView = UIImageView()
        imageView.contentMode = .scaleAspectFit
        return imageView
    }

    //Use the default label with extra modifications, such as different font and different color.
    override func setupLabel() -> UILabel {
        let label = super.setupLabel()
        label.font = UIFont(name: "Helvetica-Light", size: 16)
        label.numberOfLines = 0
        label.textColor = .white
        return label
    }

    //use a custom subclass of UIButton
    override func setupButton() -> UIButton {
        return HighlightableButton()
    }

    //setup the stack view to your liking
    override func setupStack(_ imageView: UIImageView, _ textLabel: UILabel, _ button: UIButton) -> UIStackView {
        let stack = super.setupStack(imageView, textLabel, button)
        stack.spacing = 14
        stack.alignment = .center
        button.widthAnchor.constraint(equalTo: stack.widthAnchor, multiplier: 0.8).isActive = true
        imageView.widthAnchor.constraint(equalTo: stack.widthAnchor, multiplier: 0.5).isActive = true
        return stack
    }
}
You might also like...
IHTypeWriterLabel - A simple, UILabel subclass which poulates itself as if being typed
IHTypeWriterLabel - A simple, UILabel subclass which poulates itself as if being typed

IHTypeWriterLabel A simple, UILabel subclass which poulates itself as if being typed. HighLights Written purely in SWIFT. Very simple and lightweight.

A drop-in universal library helps you to manage the navigation bar styles and makes transition animations smooth between different navigation bar styles
A drop-in universal library helps you to manage the navigation bar styles and makes transition animations smooth between different navigation bar styles

A drop-in universal library helps you to manage the navigation bar styles and makes transition animations smooth between different navigation bar styles while pushing or popping a view controller for all orientations. And you don't need to write any line of code for it, it all happens automatically.

Full configurable spreadsheet view user interfaces for iOS applications. With this framework, you can easily create complex layouts like schedule, gantt chart or timetable as if you are using Excel.
Full configurable spreadsheet view user interfaces for iOS applications. With this framework, you can easily create complex layouts like schedule, gantt chart or timetable as if you are using Excel.

kishikawakatsumi/SpreadsheetView has moved! It is being actively maintained at bannzai/SpreadsheetView. This fork was created when the project was mov

Create SwiftUI Views with any data

Create SwiftUI Views with any data

Easily use UIKit views in your SwiftUI applications. Create Xcode Previews for UIView elements
Easily use UIKit views in your SwiftUI applications. Create Xcode Previews for UIView elements

SwiftUIKitView Easily use UIKit views in SwiftUI. Convert UIView to SwiftUI View Create Xcode Previews from UIView elements SwiftUI functional updatin

Create macOS apps with Swift packages instead of Xcode projects

Swift Bundler A Swift Package Manager wrapper that allows the creation of MacOS apps with Swift packages instead of Xcode projects. My motivation is t

Create descriptive UIKit screens, faster!
Create descriptive UIKit screens, faster!

Columbina's DeclarativeUIKit Create descriptive UIKit screens, faster! Get rid of constraints manipulation and use declarative language to create your

Confetti View lets you create a magnificent confetti view in your app
Confetti View lets you create a magnificent confetti view in your app

ConfettiView Confetti View lets you create a magnificent confetti view in your app. This was inspired by House Party app's login screen. Written in Sw

Create view hierarchies declaratively.
Create view hierarchies declaratively.

Create view hierarchies declaratively. Quick Look view.pd.add( imageView.pd.image(logoImage), label.pd.text("Logo").textColor(.red).font(size:

Releases(1.0.0)
Owner
Antonio Zaitoun
24, Mobile Dev & System architect. Software Engineer at GE Healthcare. Information Systems B.Sc. Graduate and M.Sc. student at University of Haifa.
Antonio Zaitoun
Handy UIControl subclasses. (Think Three20/NimbusKit of UIControls.)

STAControls STAControls is a collection of classes that aim to make dealing with Cocoa's UIControl subclasses more convenient, and to reduce the compl

Aaron 12 Oct 30, 2019
A custom UIControl which functions like UISlider where you can set multiple intervals with different step values for each interval.

MultiStepSlider A custom UIControl which functions like UISlider where you can set multiple intervals with different step values for each interval. Th

Susmita Horrow 25 Apr 28, 2022
Protocol to handle initial Loadings, Empty Views and Error Handling in a ViewController & views

StatusProvider Protocol to handle initial Loadings, Empty Views and Error Handling in a ViewController & views CocoaPods Podfile pod 'StatusProvider'

Mario Hahn 887 Dec 22, 2022
Advanced List View for SwiftUI with pagination & different states

AdvancedList This package provides a wrapper view around the SwiftUI List view which adds pagination (through my ListPagination package) and an empty,

Chris 246 Jan 3, 2023
A child view controller framework that makes setting up your parent controllers as easy as pie.

Description Family is a child view controller framework that makes setting up your parent controllers as easy as pie. With a simple yet powerful publi

Christoffer Winterkvist 246 Dec 28, 2022
An iOS Library that makes shadows management easy on UIView.

ShadowView is an iOS Shadow library that makes view's shadow implementation easy and sweet ?? ?? . Add simple shadows to add a gaussian blurred projec

Pierre 404 Dec 8, 2022
Windless makes it easy to implement invisible layout loading view.

Windless Windless makes it easy to implement invisible layout loading view. Contents Requirements Installation Usage Looks Credits Communication Licen

ArLupin 940 Dec 22, 2022
A UINavigationController subclass that support pop interactive UINavigationbar with hidden or show.

KDInteractiveNavigationController Features ✨ UINavigationController interactive with UINavigationBar hidden or show Hide all UINavigationController ba

Kingiol 154 Dec 3, 2022
A UITextView subclass that adds support for multiline placeholder written in Swift.

KMPlaceholderTextView A UITextView subclass that adds support for multiline placeholder written in Swift. Usage You can set the value of the placehold

Zhouqi Mo 794 Jan 7, 2023
UIViewController subclass to beautifully present news articles and blog posts.

LMArticleViewController This framework allows you to create Apple News-inspired UIViewControllers with ease. It is heavily inspired by MRArticleViewCo

Luca Mozzarelli 7 Feb 3, 2022