Stretching an UIImage while preserving the corners

前端 未结 5 1189
太阳男子
太阳男子 2020-12-12 20:55

I\'m trying to stretch a navigation arrow image while preserving the edges so that the middle stretches and the ends are fixed.

Here is the image that I\'m trying to

5条回答
  •  被撕碎了的回忆
    2020-12-12 21:45

    UIImage *image = [UIImage imageNamed:@"img_loginButton.png"];
        UIEdgeInsets edgeInsets;
        edgeInsets.left = 0.0f;
        edgeInsets.top = 0.0f;
        edgeInsets.right = 5.0f; //Assume 5px will be the constant portion in your image
        edgeInsets.bottom = 0.0f;
        image = [image resizableImageWithCapInsets:edgeInsets];
    //Use this image as your controls image
    

提交回复
热议问题