Skip to content

MXCornerRadius has only one line code to help you let your imageView has its cornerRadius!

Notifications You must be signed in to change notification settings

michaelxiaonull/MXCornerRadius

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

MXCornerRadius

MXCornerRadius has only one line code to help you let your imageView has its cornerRadius!

Object Structure

Structure.png

Screenshots

whenimgView.mxCornerRadius=xxxx changed, imgView show real-time image imgView.mxDisableRoundImageCache = NO, default is NO, cache cornerRadius image can improve high FPS imgView.mxDisableRoundImageCache = YES, no cache

How To Use

Common Use

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;`

mxDisableRoundImageCache

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;

printDebugLogForRoundImageCache

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圆角!

对象结构

Structure.png

屏幕截图

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;`

mxDisableRoundImageCache

默认是 NO,启用缓存,MXImageObserver缓存圆角图片是为了提高FPS帧率;当设置为YES, 禁用缓存,当imageView有新的图片或者mxCornerRadius改变或者contentMode 改变,CPU每一次都会重新生成圆角图片,老iPhone估计会影响性能,所以建议用默认设置(启用缓存),但是要注意当- [imageView dealloc] 调用后,与imageView绑定的MXObserver对象也会被销毁,那么它缓存的所有圆角图片也会随之销毁,因此不可能有内存泄漏!具体看demo.

avatarImageView.mxDisableRoundImageCache = YES;

printDebugLogForRoundImageCache

默认是 NO,不打印信息,避免影响生产环境的性能,但在demo中已手动设置为YES;当设置为YES时,控制台会实时监听缓存图片的变化,如增加缓存,以及当- [imageView dealloc]调用后,缓存会被删除,打印出当前imageView.MXImageObserver对象已经缓存的圆角图片以及其他imageView.MXImageObserver对象已经缓存的圆角图片,它们是一个集合类型。

[MXRoundImageCacheManager sharedManager].shouldPrintDebugLogForRoundImageCache = YES;

About

MXCornerRadius has only one line code to help you let your imageView has its cornerRadius!

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published