Giter VIP home page Giter VIP logo

uiview's Introduction

1、GlowView

学习来自:YouXianMing老师Github上的GlowView

YouXianMing老师用的是类别,但是本人将其改写为继承自CALayer的普通类,然后仅仅用了很简单的类别将对外接口进行了简单的封装。所以外部调用起来也是同样的方便,可读性也是比较好的。当然,本人这么做主要原因并不是喜欢重复造轮子,而是通过自我编码的训练,对辉光UIView的实现底层所使用到的上下文绘制、核心动画、GCD中的定时器以及Runtime动态添加属性等知识进一步的熟练运用和提高:

然后简单的使用示例:

2、Use CAEmitterLayer

###粒子雪花效果和下雨效果

类:CAEmitterLayer、CAEmitterCell 解析:CAEmitterLayer:粒子发射场对象(类似火箭发射场的作用) CAEmitterCell:粒子对象

  • CAEmitterLayer的用途
    • CAEmitterLayer一直都是GPU渲染的,不会占用CPU内存
  • CAEmitterLayer的一些重要参数
  • 为什么要使用CAEmitterLayer
    • 为了节省性能
    • 可以产生非常不错的效果

####封装 CAEmitterLayer

  • 替换CAEmitterLayer成自定义UIView子类的backedLayer
使用的方法,在自定义UIView里重写一个类方法
+ (Class)layerClass{
	return [CAEmitterLayer class];
}
这样就能将UIView的属性layer的类型CALayer换成CAEmitterLayer

然后在这个自定义UIView类中添加一个CAEmitterLayer属性,并且在创建这个CALayer的时候,就能拿到这个CAEmitterLayer对象,注意哦,不要另外创建,因为layerClass的类型是CAEmitterLayer,这样原本UIView.layer类型就是这个CAEmitterLayer,不过XCode可能误以为的类型还是CALayer,就会警告,所以还需要强制类型装换它哦。

3、Use CAShapeLayer 综合示例

  • 使用了
    • 核心动画的路径转换显示动画(如果没用上核心动画,直接切换path并不会出现渐变过程的动画)
    • 颜色的隐式动画
    • 精度条的隐式动画
    • 线宽的隐式动画(gif图没有显示罢了)

4、Use CAGradientLayer

色差动画的实现.gif 图解CAGradientLayer的locations数组属性.png 用 CAGradientLayer 封装带色差动画的 View.gif

5、RainBowProgress

uiview's People

Contributors

heyang123456789 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

Watchers

 avatar  avatar

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.