coderjackyhuang / hybimagecliped Goto Github PK
View Code? Open in Web Editor NEW开源高效处理圆角的扩展,包括UIImageView、UIView、UIButton、UIImage的扩展API,可根据图片颜色生成图片带任意圆角,可给UIButton根据不同状态处理图片。所有生成图片都不会引起离屏渲染且不会引起离屏、图层混合,支持添加图片边框
License: MIT License
开源高效处理圆角的扩展,包括UIImageView、UIView、UIButton、UIImage的扩展API,可根据图片颜色生成图片带任意圆角,可给UIButton根据不同状态处理图片。所有生成图片都不会引起离屏渲染且不会引起离屏、图层混合,支持添加图片边框
License: MIT License
我看Demo中示例都是设置同样大小的圆角; 请问可以设置这样的圆角: 坐上和左下是10,右上和右下是5,这种样式的圆角.
pod search HYBImageCliped
[!] Unable to find a pod with name matching `HYBImageCliped'
rect.origin.x += borderWidth / 2.0;
rect.origin.y += borderWidth / 2.0;
rect.size.width -= borderWidth;
rect.size.height -= borderWidth;
所有类似上面这样的代码,可以用一行代码代替:
CGRect innerRect = CGRectInset(rect, borderWidth / 2.0, borderWidth / 2.0);
还有-bezierPathWithRoundedRect:cornerRadius:这个方法不应该使用,我们平时对圆角要求不高用一用没什么问题,但是你这是封装。这个贝塞尔曲线的这个方法是有问题的,比如一个边长为200的正方形,理应半径为100才是彻底的圆,但事实上确是:当半径为66~100之间都是彻底的圆,只有小于66才是非整圆,也就是说它存在一个绘制整圆的临界值,然而这个临界值并非边长的一半。
还有一个问题:就是图片超出圆角的部分应该裁剪。你的示例当中设置的圆角都正好不会使得图片超过圆角,你可以设置图片大小为400,半径为40试一试
_imageV_user_icon = [[UIImageView alloc] initWithFrame:CGRectMake(0, 15, 50, 50)]; [_imageV_user_icon setCenterX:SCREEN_WIDTH / 2.0]; [_imageV_user_icon hyb_addCornerRadius:25.0]; _imageV_user_icon.backgroundColor = whitlTestColor; [self.imageV_Header_BG addSubview:self.imageV_user_icon];
我在写用户信息的头像时候,用以上代码,就出现了四个角黑色。但是我在cell里,用同样的方法,缺没有出现黑色四个角,这是怎么回事?能帮忙解答一样吗?,下面是cell中的代码
self.imageVUserIcon = [[UIImageView alloc] init]; [self.imageVUserIcon hyb_addCornerRadius:15.0]; self.imageVUserIcon.backgroundColor = redTestColor; [self.contentView addSubview:self.imageVUserIcon]; [self.imageVUserIcon mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.contentView).offset(leftSpace); make.width.height.equalTo(@30); make.centerY.equalTo(self.contentView); }];
[self.collectionView hyb_addCorner:UIRectCornerTopLeft |UIRectCornerTopRight |UIRectCornerBottomLeft|UIRectCornerBottomRight cornerRadius:8];
首次加载含有图片的页面的时候,并不会显示圆角,当进入其他页面,再退出回到原来的页面的时候才出现圆角
在开发中经常会遇到给一个控件添加圆角效果并添加边界的需求!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.