gpt4 book ai didi

ios - 如何让 UIImage 只在特定区域拉伸(stretch)?

转载 作者:搜寻专家 更新时间:2023-10-31 21:53:37 29 4
gpt4 key购买 nike

var contentImageView: UIImageView!{
didSet{
contentImageView.image!.resizableImageWithCapInsets(UIEdgeInsets(top: 5,left: 5,bottom: 5,right: 5))
}
}

我在网上搜索后试过这段代码。

但是没有成功,结果是:

enter image description here

有没有更好的实现方式?

最佳答案

Xcode .xcassets 中有一个简洁的选项。您可以选择图像并从那里对其进行切片,以便仅在特定部分可以拉伸(stretch)下面是图像,请浏览此选项。 enter image description here enter image description here For your purpose just select the middle option (slice vertically and horizontally) for chat bubble.

  1. 为了您的目的,只需为聊天气泡选择中间选项(垂直和水平切片)。

After Slicing.

  1. 切片后。

Top Image is image with slicing. Bottom image is image without slicing.

  1. Top Image 是带有切片的图像。底部图像是没有图像切片。

借用 Bhavin 的图片进行演示 :D

关于ios - 如何让 UIImage 只在特定区域拉伸(stretch)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31823130/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com