Skip to content

kamwysoc/ContactCircularView

Repository files navigation

ContactCircularView

Version License Platform Build

Why to use

If you want to add some custom ContactsBook screen or you just need come circular view with some text or image inside, this pod is suitable for your app.

Demo

Example app

Contact screen

Examples

To run the example project, clone the repo, and run pod install from the Example directory first.

Create, apply initials from name, set font and border

let contactInitialsView = ContactCircularView()
contactInitialsView.backgroundColor = UIColor.redColor()
contactInitialsView.applyBorderWithColor(.greenColor(), andWidth: 1.0)
contactInitialsView.applyTextFont(.italicSystemFontOfSize(12), andColor: .greenColor())
contactInitialsView.applyInitialsFromName("John Doe")

Create, apply image

let contactInitialsView = ContactCircularView()
contactInitialsView.applyImage(UIImage(imageLiteral: "some_cool_image"))

Create your custom TextFormatter, and initialize ContactCircularView with it

class FirstLetterFormatter: FormattedTextCreator {

    func formattedTextFromString(string: String) -> String {
        guard let firstLetter = string.characters.first else {
            return ""
        }
        return String(firstLetter)
    }

}
let contactInitialsView = ContactCircularView(textCreator: FirstLetterFormatter())
contactInitialsView.backgroundColor = UIColor.redColor()
contactInitialsView.applyTextColor(UIColor.whiteColor())
contactInitialsView.applyFormattedTextFromString("John Doe")

Create an circularView and make the UIImage from it

let contactInitialsView = ContactCircularView(textCreator: FirstLetterFormatter())
contactInitialsView.frame = CGRectMake(0,0,30,30)
contactInitialsView.backgroundColor = UIColor.redColor()
contactInitialsView.applyTextColor(UIColor.whiteColor())
contactInitialsView.applyFormattedTextFromString("John Doe")

let image = contactInitialsView.toImage()

Requirements

version 1.1.0+ Swift 3.0, Xcode 8

version 1.0.2 Swift 2.2, Xcode 7

Installation

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

pod "ContactCircularView"

Author

Homepage

Twitter

License

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published