Coder Social home page Coder Social logo

silverfruity / uicornershadowview Goto Github PK

View Code? Open in Web Editor NEW
56.0 2.0 11.0 804 KB

iOS UIView Subclass: Use CoreGraphics to control the direction of Rect Corner、Shadow 、Border

Home Page: https://silverfruity.github.io/blogs/2020/UICornerShadowView/UICornerShadowView.html

License: MIT License

Swift 35.58% Objective-C 62.90% Ruby 1.52%
coregraphics

uicornershadowview's Introduction

CI Status Version License Platform

掘金

SFCSBView

iOS UIView Subclass: Use CoreGraphics to control the direction of Rect Corner、Shadow 、Border

Example

// UIAppearance
[SFCSBView appearance].cornerRadius = 20;
[SFCSBView appearance].rectCornner = UIRectCornerAllCorners;
[SFCSBView appearance].shadowPosition = UIShadowPostionAll;
[SFCSBView appearance].shadowRadius = 20;
[SFCSBView appearance].borderColor = [UIColor systemBlueColor];
[SFCSBView appearance].borderWidth = 5;
[SFCSBView appearance].borderPosition = UIBorderPostionAll;


SFCSBView * shadowView = [SFCSBView new];
shadowView.cornerRadius = 20;
shadowView.rectCornner = UIRectCornerAllCorners;
shadowView.shadowPosition = UIShadowPostionAll;
shadowView.shadowColor = [[UIColor blackColor]colorWithAlphaComponent:0.6];
shadowView.shadowRadius = 20;
shadowView.borderColor = UIColor.systemBlueColor;
shadowView.borderWidth = 5;
shadowView.borderPosition = UIBorderPostionAll;

Features

  1. Surpport xib / storyboard

image

  1. Using them freedomly

image

  1. Create and process image

for objc:

// Generate UIImage by color or gradient colors, then start UIImage process flow
UIColor.lightGrayColor.sf_flow.corner(10, UIRectCornerAllCorners).border(0.5, UIColor.blackColor).image;
@[UIColor.redColor,UIColor.purpleColor].sf_gradientFlow(YES,self.gradientButton.frame.size).corner(10, UIRectCornerTopLeft|UIRectCornerBottomRight).border(1, UIColor.blackColor).image

// UIImage Process Flow
[UIImage new].sf_flow.circle.resize(CGSizeMake(40, 40)).blur(SFBlurEffectLight).corner(10, UIRectEdgeAll).border(1, UIColor.redColor)

for swift:

let _ = UIColor.red
            .sf_flow(with: CGSize.init(width: 40, height: 40))
            .blur(with: SFBlurEffectLight)
            .border(withWidth: 1, color: .gray)
            .shadow(with: UIColor.black.withAlphaComponent(0.5), offset: .init(width: 10, height: 10), blurRadius: 10)
            .resize(with: .init(width: 20, height: 20))
            .circle
            .image();

CocoaPods

pod 'SFImageMaker'

Preview

Compare with CALayer

compare with CALayer

Random Cells

Review

Performance

1000 shadow images only need 29MB and 1.01s

In this condition, maximum cpu occupancy rates is 45% and 60FPS when the count of cell is 1000 and quick slide,use iPhone 7, iOS13.3.1.

In extreme cases,no reuse, maximum cpu occupancy rates is 140% and 60FPS when the count of cell is 1000 and quick slide.

Review

uicornershadowview's People

Contributors

silverfruity 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

Watchers

 avatar  avatar

uicornershadowview's Issues

darkMode 问题

当app在后台运行, 这时候切换darkmode 再讲app 进入前台, 这时候的view 背景颜色会出问题(不发生改变)

严重BUG

前提:APP适配了暗黑主题
当前在一个UITableView页面,当APP退到后台重新进入时,某些Cell会出现白色背景。经过排查发现是SFCBView内部的UIImageView对象变成了白色导致的。详情可以参考图1链接图2链接图3链接。如果链接打不开可以联系我([email protected])

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.