MXCornerRadius
has only one line code to help you let your imageView has its cornerRadius!
single avatar imageView show real-time image when cornerRadius has changed.
UIImageView *avatarImageView = [[UIImageView alloc] initWithFrame:CGRectMake(...)];
avatarImageView.image = [UIImage imageNamed:@"foo.png"];
`avatarImageView.mxCornerRadius = 10.0f;`
default is NO, MXImageObserver
caches cornerRadius image to improve FPS; when YES, CPU generate cornerRadius image each time when imageView has a new image, mxCornerRadius changes and contentMode changes, but cached images will all be released when - [imageView dealloc] called
, so there is no memory leaks!
avatarImageView.mxDisableRoundImageCache = YES;
default is NO, when YES, console logs how many cornerRadius images current MXImageObserver
has cached and other MXImageObservers
have cached when - [imageView dealloc]
called.
[MXRoundImageCacheManager sharedManager].shouldPrintDebugLogForRoundImageCache = YES;
MXCornerRadius
只需1行代码让你的imageView
有任意的cornerRadius圆角!
当imgView.mxCornerRadius=xx 改变时,单个imgView 实时显示圆角image |
imgView.mxDisableRoundImageCache = NO, 默认是NO,缓存图片,高 FPS | imgView.mxDisableRoundImageCache = YES, 不缓存图片 |
---|---|---|
当mxCornerRadius
改变时,单个avatarImageView
实时显示圆角image
UIImageView *avatarImageView = [[UIImageView alloc] initWithFrame:CGRectMake(...)];
avatarImageView.image = [UIImage imageNamed:@"foo.png"];
`avatarImageView.mxCornerRadius = 10.0f;`
默认是 NO
,启用缓存,MXImageObserver
缓存圆角图片是为了提高FPS帧率;当设置为YES
, 禁用缓存,当imageView
有新的图片或者mxCornerRadius
改变或者contentMode
改变,CPU每一次都会重新生成圆角图片,老iPhone估计会影响性能,所以建议用默认设置(启用缓存),但是要注意当- [imageView dealloc] 调用后
,与imageView
绑定的MXObserver
对象也会被销毁,那么它缓存的所有圆角图片也会随之销毁,因此不可能有内存泄漏!具体看demo
.
avatarImageView.mxDisableRoundImageCache = YES;
默认是 NO
,不打印信息,避免影响生产环境的性能,但在demo中已手动设置为YES
;当设置为YES
时,控制台会实时监听缓存图片的变化,如增加缓存,以及当- [imageView dealloc]
调用后,缓存会被删除,打印出当前imageView.MXImageObserver
对象已经缓存的圆角图片以及其他imageView.MXImageObserver
对象已经缓存的圆角图片,它们是一个集合类型。
[MXRoundImageCacheManager sharedManager].shouldPrintDebugLogForRoundImageCache = YES;