iOS:如何为蒙版UIImageView

时间:2015-11-30 15:34:40

标签: ios swift

我想在留言泡泡中显示图片。 代码:

class ViewController: UIViewController
{
    @IBOutlet weak var imageView: UIImageView!

    override func viewDidLoad()
    {
        super.viewDidLoad()
    }

    override func viewDidAppear(animated: Bool)
    {
        getMaskView()
    }

    func getMaskView()
    {
        let maskView = UIImageView(frame: CGRectMake(0, 0, 200, 200))
        maskView.image = UIImage(named: "BubbleGreen")?.stretchableImageWithLeftCapWidth(20, topCapHeight: 15)
        imageView.layer.mask = maskView.layer
    }
}

结果是:

enter image description here

现在,我想为此气泡设置边框,例如,width = 2,color = red。我尝试了很多方法,但无论如何都失败了。任何解决方案?

0 个答案:

没有答案