Loading...

Using Swift View

Photoshop layers to Swift with clean and clear code becomes simple with Layer Kit – Swift View. Translate your PSD layers to Swift with advanced support for text, images and shapes.

Get Layer Kit Pro to add layer effects, imaging options and more with Swift View.

Example Image Element

1
2
3
4
5
6
7
//you must import your image
let button_copy_view = UIImageView(frame:CGRectMake(446, 240, 310, 166))
let button_copy = UIImage(named:"button_copy.png")
 
button_copy_view.image = button_copy
 
self.view.addSubview(button_copy_view)

Example Text Element

1
2
3
4
5
6
7
8
9
10
11
12
13
let text:UITextField = UITextField(frame:CGRectMake(132, 501, 227, 90))
let text_font:UIFont = UIFont(name:"ArialMT", size:68)
let text_str = "TEXT"
let text_textColor:UIColor = UIColor(red:255.0, green:255.0, blue:255.0, alpha:1)
let text_textStr = NSAttributedString(string:text_str)
 
text_textStr.addAttribute(NSKernAttributeName, value:2.0)
text_textStr.addAttribute(NSFontAttributeName, value:text_font)
text_textStr.addAttribute(NSForegroundColorAttributeName, value:text_textColor)
 
text.attributedText = text_textStr
 
self.view.addSubview(text)

Example Shape Element

1
2
3
4
5
6
7
8
9
10
11
12
//Its better to sub-class this
override func drawRect(rect:CGRect){
 
    let button_bg_context = UIGraphicsGetCurrentContext()
    let button_bg_rectangle = CGRectMake(72, 449, 310, 159)
 
    CGContextAddRect(button_bg_context, button_bg_rectangle)
    CGContextSetFillColorWithColor(button_bg_context, UIColor(red:206.0, green:54.0, blue:54.0).CGColor)
    CGContextFillRect(button_bg_context, button_bg_rectangle)
 
    self.view.layer.cornerRadius = 30
}

Pro Features

Using Layer Kit Pro, you can customize the Swift View to include additional information with the PSD layer such as effects, advanced text rendering and more.

Example Layer Effects

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
let text:UITextField = UITextField(frame:CGRectMake(132, 501, 227, 90))
let text_font:UIFont = UIFont(name:"ArialMT", size:68)
let text_str = "TEXT"
let text_textColor:UIColor = UIColor(red:206.0, green:54.0, blue:54.0, alpha:1)
let text_textStr = NSAttributedString(string:text_str)
let text_shadow:NSShadow = NSShadow()
 
text_shadow.shadowColor = UIColor(red:0 green:0, blue:0).CGColor
text_shadow.shadowOffset = CGSizeMake(-4f, 3f)
text_shadow.shadowOpacity = 0.8f
text_shadow.shadowRadius  = 2.5f
 
text_textStr.addAttribute(NSKernAttributeName, value:2.0)
text_textStr.addAttribute(NSFontAttributeName, value:text_font)
text_textStr.addAttribute(NSForegroundColorAttributeName, value:text_textColor)
text_textStr.addAttribute(NSShadowAttributeName, value:text_shadow)
 
text.attributedText = text_textStr
 
self.view.addSubview(text)

Example Inline Content

1
2
3
4
5
6
7
8
9
10
11
12
let button_bg:UIView = UIView(frame:CGRectMake(72, 449, 310, 159))
 
button_bg.cornerRadius = 30
 
button_bg.shadowColor = UIColor(red:206.0, green:54.0, blue:54.0).CGColor
button_bg.shadowOffset = CGSizeZero
button_bg.shadowOpacity = 0.8f
button_bg.shadowRadius  = 12.5f
 
button_bg.backgroundColor = UIColor(red:206.0, green:54.0, blue:54.0).CGColor
 
self.view.addSubview(button_bg)

LOGIN NOW: Get instant access to our free Online Training - click here.

Products For Android Professionals


android_pack

Android Pack

android_pack

Android Pack (6 Months)

android_pack

Android Pack

Need a custom solution?

Try our Shop!

Using the Plugin

Layer Support

Layer Tags

How To Guides

Optimization Tips

Help Us Improve


We aim to keep our content relevant with useful information, examples, samples and links. Tell us what you think!

I found the content:

Helpful
Confusing
Outdated
Broken Links
Bad Spelling
Too Short
Too Long

This page needs:

Nothing
Better Content
Links
Examples
Videos

Free Download


One Pager Website

A clean professional single page website design.

Start Your 14 Day Free Trial

New users get instant access to the 14 Day Free Trial with all features enabled, and Free Online Training. We guarantee your first conversion will 100% work - we work with you to ensure this, contact us or check our FAQs for assistance.

Connect With Us

Top