Valeriy Bezuglyy

12pods

Mirage

License: MIT

UIKit+VBProgrammaticCreation

UIKit+VBProgrammaticCreation is a set of categories for UIKit classes (UIView, UIButton, UIBarButtonItem, ...) which help to create readable code if you instantiate ui elements programmatically.

License: MIT

  • Objective C

VBAutolayout

There are developers (like me) who prefer to create UI programmatically due to numerous reasons. I use storyboards for segues and user scene-path. But UIViewControllers are left empty. And I do not use xibs.

When you create adaptive UI programmatically the view (or viewcontroller) code becomes unreadable because of big autolayout creation calls.

VBAutolayout is a library which makes programmatic autolayout creation comfortable, readable and code-minimized.

Format

Views layout is described in a dictionary with special VBAutolayout format. Constraints are created only for VBAutolayoutAttribute-s contained in layout dictionary. Attribute is ignored if no VBAutolayoutConstant value was given.

Layout dictionary format:

@{VBAutolayoutAttribute: <1>,
  VBAutolayoutAttribute: <2>,
  VBAutolayoutAttribute: <3>
}

<1> =  <const>

<2> =  @{VBAutolayoutItem: <item>,
         VBAutolayoutConstant: <const>}

<3> =  @[<1>, <2>, ...]

is a view2 in constraint. If no specified, then superview is used and constraint is interpreted as a constraint to view container.

is a string with the same format as could be used for Visual Format Constraints Creation

<const> = <relation><constant>@<priority>, ex. 10, ==10, >=10, <=10, 10@999, >=10@999, etc.
<relation> =    1) <, <= for <=
                2) >, >= for >=
                3) =, == for ==

Several constraints can be combined for one attribute using variant .

Examples,

  • distance greater or equal then 10 from item top to someView bottom with 999 priority VBAutolayoutAttributeTop: @{VBAutolayoutItem: someView, VBAutolayoutConstant: @">=10@999"}
  • distance equal to 0 from item leading to someView trailing VBAutolayoutAttributeLeading: @{VBAutolayoutItem: someView}
  • distance equal to 0 from item leading to container leading VBAutolayoutAttributeLeading: @"0"

License: MIT

  • Objective C

VBCollectionViewController

VBCollectionViewController extends UICollectionViewController by adding pagination, pull-to-refresh and other useful features.

VBCollectionViewCell is a base class for cells. Each cell contains only apporpriate VBCollectionViewCellView as a subview. The idea is to setup UI of VBCollectionViewCellView by setting its item property (which calls updateUI).

VBCollectionViewHeader uses the same idea as VBCollectionViewCell.

License: MIT

  • Objective C

VBDefines

Useful objective-c defines.

For example, VBLog is a NSLog redefine. It adds some additional info (caller class, line) to log message. Stops logging in non-DEBUG builds.

License: MIT

  • Objective C

VBError

VBError is a base class for your own errors. It makes error creation and handling more effective.

When handling error you can check class instead of making domain+code check.

You can also create same errors(domain+code) in different parts of code by creating an instance of the same VBError subclass.

Use case 1.

  1. Create VBError subclass.
  2. Implement +domain value.
  3. Call +errorWithCode: or +errorWithCode:userInfo: to create an instance.

Use case 2

  1. Create VBError subclass.
  2. Implement +domain and +code values.
  3. Call +error, +errorWithUserInfo: to create an instance.

License: MIT

  • Objective C

VBException

VBException is a base class for your own exceptions. It makes exception creation and handling more effective.

Use case

  1. Create VBException subclass.
  2. Implement +reasonWithUserInfo: method.
  3. Call +exception: or +exceptionWithUserInfo: to create an instance.

By default, exception name is its classname. It can be changed by implementing +name method.

License: MIT

  • Objective C

VBRandom

VBRandom is a pseudo-random numbers generator. Using of VBRandom simplifies random numbers creation code.

It uses arc4random() function.

Supported features

  1. random NSUInteger
  2. random NSInteger
  3. random double
  4. random BOOL

License

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

License: MIT

  • Objective C

VBTableViewController

VBTableViewController extends UITableViewController by adding pagination, pull-to-refresh and other useful features.

VBTableViewCell is a base class for cells. Each cell contains only apporpriate VBTableViewCellView as a subview. The idea is to setup UI of VBTableViewCellView by setting its item property (which calls updateUI).

VBTableViewHeader uses the same idea as VBTableViewCell.

License: MIT

  • Objective C

VBVerticalScrollView

VBVerticalScrollView limits scrolling to only vertical direction by resizing its contentView.

According to Apple docs when working with UIScrollView you should put all views into one contentView which will be added to scrollView itself.

Use case

  1. Create view with information to be scrolled (do not forget to set constraints)
  2. verticalScrollView.contentView = myContentView;

License: MIT

  • Objective C