How to let a UIImage only stretch in a specific area?

前端 未结 2 1110
甜味超标
甜味超标 2020-12-16 08:21
var contentImageView: UIImageView!{
    didSet{
        contentImageView.image!.resizableImageWithCapInsets(UIEdgeInsets(top: 5,left: 5,bottom: 5,right: 5))
    }
}
         


        
2条回答
  •  离开以前
    2020-12-16 09:00

    There is a sleek option in Xcode .xcassets. You can select the images and slice it from there so that it's strechable in specific parts only below are the images please explore this option.

    1. 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.

    Borrowed Bhavin's Image for demonstration :D

提交回复
热议问题