2017-12-07 26 views
1

는 내가있는 UIImageView를 설정하는 함수를 호출하고 있습니다.이미지보기 이중 테두리

imageView.image = imageConstants.imageThatIsWanted 
imageView.clipsToBounds = true 
imageView.layer.cornerRadius = imageView.frame.height/2 
imageView.layer.borderWidth = 3.0 
imageView.layer.borderColor = UIColor.white.cgColor 

흰색 테두리가 주위에 푸른 색의 두 번째의 borderColor을 적용하는 가장 좋은 방법은 무엇입니까 : 여기

내가 현재 무엇을하고 무엇인가?

CALayer로 하위 레이어를 만들고 파란색 테두리를 지정해 보았습니다.하지만이 이미지는 물론 흰색 테두리 안에 있습니다. 또한 UIBezierPath 그리기 시도했지만 흰색 경계 안쪽에도 유지됩니다.

+1

당신은 이미지보기가 더 큰'UIView'의 하위 뷰가 될 수 있도록 할 수 없습니다? 높이/너비가 6 포인트 더 많은 것이고 파란색 테두리가 있습니까? – dfd

답변

0
import UIKit 

class ViewController: UIViewController { 

    @IBOutlet weak var secondView: UIView! 
    @IBOutlet weak var imgView: UIImageView! 
    override func viewDidLoad() { 
     super.viewDidLoad() 
     imgView.layer.cornerRadius = imgView.frame.size.height/2 
     secondView.layer.cornerRadius = secondView.frame.size.height/2 
     imgView.layer.borderWidth = 5.0 
     imgView.layer.borderColor = UIColor.red.cgColor 
     imgView.clipsToBounds = true 
     secondView.clipsToBounds = true 
     // Do any additional setup after loading the view, typically from a nib. 
    } 

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


} 

enter image description here