【问题标题】:Change border of an image on Xcode 6.3在 Xcode 6.3 上更改图像的边框
【发布时间】:2015-05-19 07:19:16
【问题描述】:
我正在使用此功能制作游戏:
if (CGRectIntersectsRect(object.frame, object2.frame)) {
[self GameOver];
}
两个对象都是方形的,但是object #2 的图像不是。
因此,当边界碰撞(但不是实际图片)时,游戏结束。有没有办法让图像的边框“适合”,这样游戏只会在实际图片发生碰撞时结束。
谢谢:)
【问题讨论】:
标签:
xcode
image
border
frame
collision
【解决方案1】:
您可以将图像大小设置为:
UIImage *object2 = [[UIImage imageNamed:@"blueImage"]
resizableImageWithCapInsets:UIEdgeInsetsMake(12, 12, 12, 12)];
并且您可以将图像视图的边框设置为
UIImageView *imgView=[UIImageView alloc]init];
imgView.layer.borderWidth=4.0f; //设置图像视图的边框
也许这会有所帮助。