Author Topic: How to Add a Border to an Image View  (Read 3797 times)

kjmcneish

  • Administrator
  • *****
  • Posts: 719
    • View Profile
How to Add a Border to an Image View
« on: January 26, 2016, 02:53:04 PM »
It takes just two lines of code to add a border to an image view.

In Swift:

Code: [Select]
imageView.layer.borderWidth = 2.0
imageView.layer.borderColor = UIColor.whiteColor().CGColor

In Objective-C:

Code: [Select]
[[imageView layer] setBorderWidth:2.0f];
[[imageView layer] setBorderColor:[UIColor whiteColor].CGColor];

All the best!
Kevin McNeish
Author of Learn to Code in Swift: https://itunes.apple.com/us/book/learn-to-code-in-swift/id942956811?mt=11
Check out our Robot Tic-Tac-Toe app: https://itunes.apple.com/us/app/robot-tic-tac-toe/id990638517?mt=8