Platformsios 9.0
DependenciesSnapKit, DKImagePickerController, ImageViewer, Kingfisher

Common UI Tools for personal use

Table Of Contents


Notifies user of an action that just happened.


let alertViewProvider = AlertViewProvider(title: String, detail: String, actionTitle: String, type: FlashViewType)
bulletinProvider.present(in: myViewController)


Shows a message with action and cancel button
suitable for notifying the user that something happens which needs an action to be performed or be canceled


let bulletinProvider = BulletinProvider(title: String, detail: String, image: UIImage? = nil, actionTitle: String?, cancelTitle: String?)
bulletinProvider.delegate = self
bulletinProvider.present(in: myViewController)
bulletinProvider.dismiss() // will dismiss the controller
// delegate
func bulletin(actionClicked provider: BulletinAlertProvider)
func bulletin(cancelClicked provider: BulletinAlertProvider)


Simple view for showing error message
Suitable for when internet is disconnected
Used in the MSTableViewController as the showError view

let errorView = ErrorView(message: String, image: UIImage?)
// add to msView or subView of UIViewController


Notification allows you to show a message on top of the window for a short period of time


let notificationProvider = NotificationProvider(text: "this is a simple notification", type: .sucess)
// will show the notification in the top most window
// will show the notification in the current controller
notificationProvider.present(in: myViewController)


FlashView shows an animated view, which can be of success, error or custom
The animationDuration and edgeInsets can be configured BEFORE callling the present method


let flashProvider = FlashProvider(type: FlashViewType)


Extend the UIViewController from ImageViewerExtension and then call the following method

  • presentImage(image: UIImage) which will show the gallery with the provided image


View for showing a button that can transform into loading state.

IMPORTANT: it’s best to not set height and width constraint since the loading animation relies on intrinsic content size

let loadingButton = LoadingButton(title: String, type: LoadingButtonType)


This extension enables the UIImageView to load a URL async
The image is then resized and shrinked to the bounds size

imageView.url = ""
imageView.cornerToBounds = true // set the radius accordning to bounds
imageView.defaultImage = my_playholder_img // set image for when the UIImageView is empty


Displays a loading indicator.
The width and height constrainsts aren’t needed since the intrinsic content size is provided

let loadingView = LoadingView(type: LoadingViewType, color: LoadingViewColorType)

LoadingViewType.normal // size is 40
LoadingViewType.small // size is 25
LoadingViewColorType.default // #CCCCCC
LoadingViewColorType.accent // the accent
LoadingViewColorType.white // #FFFFFF

MSView & MSViewController

This view enabled multiple views to be displayed with fadein/fadeout transition

let msView = MSView()
msView.animationDuration = 0.5 // duration of animation, default: 0.15
msView.currentView // returns the current visible view
msView.animate(to: nextView)
class MyMSViewControler: MSViewController {

    override viewDidLoad() {
        animate(to: nextView)



Allows the user to select one or many items from the provided view


The user can only select one option

let provider = SelectOptionProvider<Int>(headerTitle: String? = nil, cancelTitle: String)
provider.appendItem(title: "first option", value: 1)
provider.insertItem(title: "second option", value: 2, at: 1)
provider.present(in: myViewController)
provider.onResult { result in
    switch result {
        case .cancel: break
        case .value(let value): // value is same type as T


The user can pick one or multiple values from the picker view

let provider = SelectOptionProvider<Int>(headerTitle: String? = nil, cancelTitle: String)
provider.addItem("one", value: 1, component: 0)
provider.addItem("two", value: 2, component: 0)
provider.addItem("three", value: 3, component: 0)
provider.present(in: myViewController)
provider.onResult { result in
    switch result {
        case .cancel: break
        case .value(let value):
            // array containing dictionary [Component: Valye]
            let valueForComponent = value[0]


extend view controller to implement the SelectImageProtocol, then implement the following method

  • func imageSelectionSucceed(images: [UIImage])
  • func imageSelectionCanceled()
    to call the selectImageController call presentSelectImage(config) and pass the config

    let config = SelectImageConfig()
    config.selectionCount = 1 //default
    config.sourceType: DKImagePickerControllerSourceType = .both // default, means both camera and gallery
    config.showCancelButton = true // default
    self.presentSelectImage(config: config)


Gloabl styles

Known Bugs And Limitations

  • cannot change the size of image in the BulletinAlert
  • ErrorView does not have an action


mohsenShakiba, [email protected]


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

Latest podspec

    "name": "CUITools",
    "version": "0.9.7",
    "summary": "UI tools for internal usage",
    "description": "UI tools for usage in internal apps.nincluding loading, select and more",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "mohsenShakiba": "[email protected]"
    "source": {
        "git": "",
        "tag": "0.9.7"
    "platforms": {
        "ios": "9.0"
    "source_files": "CUITools/Classes/**/*",
    "resource_bundles": {
        "CUITools": [
    "dependencies": {
        "SnapKit": [
            "< 4.0.0"
        "DKImagePickerController": [
            "< 3.8.0"
        "ImageViewer": [
            "~> 4.0"
        "Kingfisher": [
            "~> 4.6"
    "pushed_with_swift_version": "3.2"

Pin It on Pinterest

Share This