Latest 0.2
License MIT
Platforms ios 6.0, requires ARC


A custom UIView subclass to easily turn on drawing of each single border on a view.


Usage is easy.

Add the dependency to your Podfile:

platform :ios
pod 'TWRBorderedView'

Run pod install to install the dependencies.

Next, import the header file wherever you want to use the custom view:

#import "TWRBorderedView.h"

The bordered view can be set up either via Interface Builder (XIB and Storyboards) or programmatically.

Interface Builder

Just set up TWRBorderedView as the class of any UIView and use the Identity Inspector to set User Defined Runtime Attributes.

The following key paths can be defined:

  • topBorder (Boolean) – a YES value will draw the border
  • bottomBorder (Boolean)
  • leftBorder (Boolean)
  • rightBorder (Boolean)
  • borderColor (Color)
  • borderWidth (Number) – in points

Here is an example of how it looks like setting the properties from Xcode’s Interface Builder:


If you prefer adding you subviews from code, you can work with TWRBorderedView programmatically with a pretty sweet one-liner:

CGRect borderedViewRect = CGRectMake(0, 0, 100, 100);
TWRBorderMask mask = (TWRBorderMaskBottom | TWRBorderMaskTop);
TWRBorderedView *borderedView = [[TWRBorderedView alloc] initWithFrame:borderedViewRect
                                                                 color:[UIColor greenColor]
[self.view addSubview:borderedView];


The following screenshot is a very basic demonstration of the two ways of dealing with borders.

The two red views at the top and at the bottom have been defined from IB. The top one has a bottom border and the bottom one has a border on the top.

The two green views have both 3 borders and have been added as subviews from code. You can download the demo project to run the example by yourself.


TWRBorderedView requires iOS 6.x or greater.


Usage is provided under the MIT License. See LICENSE for the full details.

Latest podspec

    "name": "TWRBorderedView",
    "version": "0.2",
    "summary": "A custom UIView subclass to easily turn on drawing of each single border on a view.",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "Michelangelo Chasseur": "[email protected]"
    "social_media_url": "",
    "source": {
        "git": "",
        "tag": "0.2"
    "platforms": {
        "ios": "6.0"
    "source_files": "TWRBorderedView/*.{h,m}",
    "requires_arc": true

Pin It on Pinterest

Share This