UIImageView能用来做sprite吗?

为什么在storyboard里面都是隐藏的,但是编译之后还是显示出来了?

UIImageView控件怎么让超出控件范围的图像信息隐藏

杨魅力
浏览 341回答 1
1回答

SMILET

imageView.clipsToBounds = YES;have a try想修改图片于View的相对坐标,可以增加一个CALayer用于存放图片,或者索性将一个UIImageView *a作为另一个UIView *b的subview,然后调整a的frame。下面代码示范了如何使用CAlayer做到修改图片坐标此类继承自UIView,setImageFrame方法可以修改图片相对于View的坐标或大小等。////&nbsp;&nbsp;OTImageView.m//&nbsp;&nbsp;ClipDemo////&nbsp;&nbsp;Created&nbsp;by&nbsp;openthread&nbsp;on&nbsp;5/31/12.//&nbsp;&nbsp;Copyright&nbsp;(c)&nbsp;2012&nbsp;__MyCompanyName__.&nbsp;All&nbsp;rights&nbsp;reserved.//#import&nbsp;"OTImageView.h"#import&nbsp;<QuartzCore/QuartzCore.h>@implementation&nbsp;OTImageView{&nbsp;&nbsp;&nbsp;&nbsp;CALayer&nbsp;*_imageLayer; }#pragma&nbsp;mark&nbsp;-&nbsp;Image&nbsp;Methods-&nbsp;(UIImage&nbsp;*)image {&nbsp;&nbsp;&nbsp;&nbsp;CGImageRef&nbsp;imageRef&nbsp;=&nbsp;(__bridge&nbsp;CGImageRef)_imageLayer.contents;&nbsp;&nbsp;&nbsp;&nbsp;UIImage&nbsp;*image&nbsp;=&nbsp;[UIImage&nbsp;imageWithCGImage:imageRef];&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;image; } -&nbsp;(void)setImage:(UIImage&nbsp;*)imag
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java