Popularity
0.2
Growing
Activity
0.0
Stable
2
1
0

Programming language: Swift
License: MIT License
Tags: UI     iOS     Swift     Generic     Builder-pattern    

EKBuilder alternatives and similar libraries

Based on the "UI" category.
Alternatively, view EKBuilder alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of EKBuilder or a related project?

Add another 'UI' Library

README

Builder

contributions welcome Swift Version CocoaPods Build Status Carthage compatible

โœ‹ โœ‹ โœ‹ The super easy and generic builder pattern. It's easy if you try ๐Ÿ’ช.

Introduction

Initialize UIView build set its properties. ๐Ÿ‘ ๐Ÿ‘

let label:UIView = .build{
  $0.backgroundColor = .red
  $0.clipsToBounds = true
}

๐Ÿ‘‡ ๐Ÿ‘‡ This is equivalent to: ๐Ÿ‘‡ ๐Ÿ‘‡

let label: UIView = {
  let view = UIView()
  view.backgroundColor = .red
  view.clipsToBounds = true
  return view
}()

Tips and examples

  • You can use build to all of NSObject subclasses.
    let view = UIView.build { // Example 1
      $0.color = .red
    }
    
    let view:UIView = .build { (view) in // Example 2
       view.color = .red
    }
    
    let view:UIView = .build { // Example 2
      $0.color = .red
    }
    
  • You can use build to all of class and structure. Just make extensions. Init implementation is required for the class, not required for the structure
    extension UserType: EKBuilder {}
    
    let instance:UserType = .build{
      $0.value = "it's easy if you try!"
    }
    
  • Example: Here's an example usage in an UIViewController subclass.
     class Tesla: EKBuilder {
            var type:String!
            var count:Int!
            required init() {}
     }
    
     struct Audi:EKBuilder {
            var type:String!
            var count:Int!
     }
    
    final class ViewController: UIViewController {
    
      let tesla:Tesla = .build {
        $0.type = "Model X"
        $0.count = 10
      }
    
      let audi = Audi.build {
         $0.type = "R8"
         $0.count = 10
      }
    
      override func viewDidLoad() {
        super.viewDidLoad()
        print(tesla.type, tesla.count)
        print(audi.type, audi.count)
      }
    
    }
    

Installation

CocoaPods

Add the following entry to your Podfile:

pod 'EKBuilder'

Then run pod install.

Don't forget to import EKBuilder in every file you'd like to use Hero.

Carthage

Add the following entry to your Cartfile:

github "erikkamalov/EKBuilder"

Then run carthage update.

If this is your first time using Carthage in the project, you'll need to go through some additional steps as explained over at Carthage.

License

EKBuilder is under MIT license. See the [LICENSE](LICENSE) file for more info.


*Note that all licence references and agreements mentioned in the EKBuilder README section above are relevant to that project's source code only.