GithubHelp home page GithubHelp logo

shevakuilin / skarchcutter Goto Github PK

View Code? Open in Web Editor NEW
82.0 3.0 16.0 348 KB

SKArchCutter是一个可自选切割角的圆角切割工具,同时支持UIView、UIImageView、UIButton和UILabel的单角切圆/选角拱形切圆/全角切圆,并且避免了UIImageView使用系统圆角所导致的离屏渲染的问题,以及确保layer对象的masksToBounds属性始终为NO,从而使得项目中大量使用圆角时的性能得到很大程度的优化, 最重要的是使用简单、方便。

License: MIT License

Objective-C 99.40% Ruby 0.60%
uiimage imagecutter objective-c

skarchcutter's Introduction

简述

SKArchCutter是一个可自选切割角的圆角切割工具,同时支持UIView、UIImageView、UIButton和UILabel的单角切圆/选角拱形切圆/全角切圆,并且避免了UIImageView使用系统圆角所导致的离屏渲染的问题,以及确保layer对象的masksToBounds属性始终为NO,从而使得项目中大量使用圆角时的性能得到很大程度的优化, 最重要的是使用简单、方便。如果觉得还不错,star支持下吧~

最新更新

  • Swift 版

  • 解决使用Masonry布局无法及时获取frame信息的兼容问题

  • 解决使用border而导致的失效问题

  • 改为类方法,使用更加简单方便

  • 注意:如果之前设置了borderbackgroundColor请取消,关闭masksToBounds(如果打开了话), 请在方法中进行设置

效果图

测试性能

如何开始

1.从GitHub上Clone-->SKArchCutter,然后查看Demo

2.直接将目录下的SKArchCutter拷贝到工程中,或在podfile文件夹中添加 pod 'SKArchCutter'

3.如果觉得还不错,点个star吧~

使用方法

头文件导入

#import "SKArchCutter.h"

进行圆角切割

UIView/UIButton/UILabel

[SKArchCutter cuttingView:self.centerView cuttingDirection:UIRectCornerTopRight | UIRectCornerTopLeft cornerRadii:self.centerView.frame.size.height / 2 borderWidth:1 borderColor:[UIColor purpleColor] backgroundColor:[UIColor redColor]];

UIImageView

[SKArchCutter cuttingImageView:self.topImageView cuttingDirection:UIRectCornerAllCorners cornerRadii:self.topImageView.frame.size.height / 2 borderWidth:1 borderColor:[UIColor blackColor] backgroundColor:[UIColor clearColor]];

感谢你花时间阅读以上内容, 如果这个项目能够帮助到你,记得告诉我

Email: [email protected]

skarchcutter's People

Contributors

shevakuilin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

skarchcutter's Issues

代码冗余

除了 UIImageView,其他的 UIView、UIButton、UILabel 的实现都是一样的,完全可以将这些方法作为分类,在 UIView 里实现一次就可以了。

一些疑问

    • (void)cuttingImageView:(UIImageView *)imageView和+ (void)cuttingView:(UIView *)view的两个方法分别使用了不同的绘制圆角的方法,这是为什么呢?
  1. if ([image isKindOfClass:[UIImage class]]) 这个判断是什么情况下会是NO?我觉得应该是if (image != nil)的判断才对,不知道您是怎么考虑的?
  2. 判定没有初始化frame的逻辑感觉不是很精准。

对 UILabel 设置圆角的 bug

wx20170421-181505
对 UILabel 设置圆角时 ,结果是一个圆角 UIImageView 加在了 label 视图上

// Masonry 添加约束后设置的圆角
[SKArchCutter cuttingView:self.label cuttingDirection:UIRectCornerAllCorners cornerRadii:10 borderWidth:0 borderColor:[UIColor clearColor] backgroundColor:[UIColor redColor]];
- (UILabel *)label {
    if (!_label) {
        _label = [[UILabel alloc] init];
        _label.numberOfLines = 0;
    }
    return _label;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.