小编Com*_*ade的帖子

如何将 UIView 的边框放在 UIImage 后面?

我是 Swift 的新手,在尝试开发一个小应用程序时遇到了一个问题,我真的希望有人能帮助我。

基本上,我在 UIView 中有一个 UIImage,我想将 UIView 的边框发送到后面(见下图)

图像前面的边框

所以,我给 UIView 一个边框,它穿过我的图像。我的问题是:

如何将 UIView 的边框放在 UIImage 后面?

注意:如果这是一个重复的问题,我深表歉意,我一直在寻找答案几个小时,但找不到我需要的。

此致!

这是我的图像代码:

speakerImage.layer.cornerRadius = speakerImage.frame.size.width / 2;
speakerImage.clipsToBounds = true;
speakerImage.layer.zPosition = 1
Run Code Online (Sandbox Code Playgroud)

这是我的视图代码:

speakerContentView.layer.cornerRadius = 5
speakerContentView.layer.borderWidth = 1
speakerContentView.layer.borderColor = UIColor.gray.cgColor
speakerContentView.layer.shadowColor = UIColor.gray.cgColor
speakerContentView.layer.shadowOpacity = 0.7
speakerContentView.layer.shadowOffset = CGSize(width: 0, height: 3)
speakerContentView.layer.zPosition = -1
Run Code Online (Sandbox Code Playgroud)

uiview uiimage ios swift

5
推荐指数
1
解决办法
356
查看次数

标签 统计

ios ×1

swift ×1

uiimage ×1

uiview ×1