Latest 0.1.0
Homepage https://github.com/taji-taji/TJView
License MIT
Platforms ios 9.0, requires ARC
Authors

Version
License
Platform

This is subclass of UIView.
You can customize the border of each side individually.(border width, border color and corner radius)

demo

Usage

Initialize

TJView can initialize from code or StoryBoard.

  • initWithFrame
  • initWithCoder

Properties

  • border width
    • public var topBorderWidth: CGFloat
    • public var bottomBorderWidth: CGFloat
    • public var leftBorderWidth: CGFloat
    • public var rightBorderWidth: CGFloat
  • border color
    • public var topBorderColor: UIColor?
    • public var bottomBorderColor: UIColor?
    • public var leftBorderColor: UIColor?
    • public var rightBorderColor: UIColor?
  • corner radius
    • public var cornerRadius: CGFloat = 0
    • public var cornerRadiusTopLeft: Bool = false
    • public var cornerRadiusTopRight: Bool = false
    • public var cornerRadiusBottomLeft: Bool = false
    • public var cornerRadiusBottomRight: Bool = false

Methods

  • public func borderPositions(positions: [TJViewBorderPosition], borderWidth: CGFloat, borderColor: UIColor?)
  • public func borderTop(borderWidth: CGFloat, borderColor: UIColor?)
  • public func borderBottom(borderWidth: CGFloat, borderColor: UIColor?)
  • public func borderLeft(borderWidth: CGFloat, borderColor: UIColor?)
  • public func borderRight(borderWidth: CGFloat, borderColor: UIColor?)
  • public func cornerRadiusPositions(corners: UIRectCorner, cornerWidth: CGFloat)

Enum

  • TJViewBorderPosition
public enum TJViewBorderPosition {
    case Top
    case Right
    case Bottom
    case Left
}

Example

From StoryBoard

demo

From Code

// ViewController.swift

import UIKit
import TJView

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        let frame = CGRectMake(10, 200, 200, 100)
        let subView = TJView(frame: frame)
        subView.backgroundColor = UIColor.whiteColor()
        subView.topBorderWidth = 10
        subView.topBorderColor = UIColor.redColor()
        subView.cornerRadiusTopRight = true
        subView.cornerRadius = 5.5

        self.view.addSubview(subView)

        let frame2 = CGRectMake(10, 310, 250, 100)
        let subView2 = TJView(frame: frame2)
        subView2.backgroundColor = UIColor.whiteColor()
        subView2.borderPositions([.Top, .Bottom], borderWidth: 3.5, borderColor: UIColor.greenColor())

        self.view.addSubview(subView2)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

}

Requirements

Installation

TJView is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "TJView"

Author

Yutaka Tajika

License

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

Latest podspec

{
    "name": "TJView",
    "version": "0.1.0",
    "summary": "TJView is a View with customizable border.",
    "description": "This is subclass of UIView. You can customize the border of each side individually.(border width, border color and corner radius)",
    "homepage": "https://github.com/taji-taji/TJView",
    "license": "MIT",
    "authors": {
        "Yutaka Tajika": ""
    },
    "source": {
        "git": "https://github.com/taji-taji/TJView.git",
        "tag": "0.1.0"
    },
    "platforms": {
        "ios": "9.0"
    },
    "requires_arc": true,
    "source_files": "Pod/Classes/**/*",
    "resource_bundles": {
        "TJView": [
            "Pod/Assets/*.png"
        ]
    }
}

Pin It on Pinterest

Share This