美文网首页
CALayer--to be continued

CALayer--to be continued

作者: 四毛哥掉落的鳞片 | 来源:发表于2016-06-28 16:12 被阅读0次

CALayer sits beneath all your UIViews (that's the parent of UIButton, UILabel, and so on), so it's like an exposed underbelly giving you lots of options for modifying the appearance of views, as long as you don't mind dealing with a little more complexity.

为了给button添加边界,使用calayer的borderWidth:

button.layer.borderWidth = 1

it draws a one point black line around the button. the line is black by default, but you can change the colour by using UIColor data type. CALayer sits at a lower technical level than UIButton, which means it doesn't understand what a UIColor is. UIButton knows what a UIColor is because they are both at the same technical level, but CALayer is below UIButton, so UIColor is a mystery.

Don't despair, though: CALayer has its own way of setting colors called CGColor, which comes from Apple's Core Graphics framework. This, like CALayer, is at a lower level than UIButton, so the two can talk happily – again, as long as you're happy with the extra complexity. Even better, UIColor (which sits above CGColor) is able to convert to and from CGColor easily, which means you don't need to worry about the complexity – hurray!

button.layer.borderColor = UIColor.lightGrayColor().CGColor

相关文章

  • CALayer--to be continued

    CALayer sits beneath all your UIViews (that's the parent ...

  • CodeForces 305B

    E - Continued FractionsA continued fraction of height n i...

  • To Be Continued

    如果有一天,有个人,不论他是谁,他面带微笑来问我,我以后想干什么,我一定要告诉他,我有很多事想做。 ...

  • to be continued

    最近的我,处于能量低频状态。如果说七年就是一辈子,我现在正处在一个轮回的末尾处。这是一种难以形容的感受...

  • To be continued

    岁月漫长的旅途,总会有别致的风景,在每个驿站,每个落脚点。 无需感慨流逝的光阴,远客会带来新的风景,陪着你踏上新的...

  • To be continued……💗

    东方金字塔-西夏王陵(宁夏银川)贺兰山 新疆 楼兰古国 重庆 学习强国收藏 四川- 三星堆博物馆遗址 陕西西安-...

  • To be continued

    我终于又一次看完了旧时光。他们说最好的故事是未完待续(to be continued.)所以,当每一个我喜欢的故事...

  • To be continued

    未完不一定待续

  • to be continued

    如题

  • to be continued

    今天是28号,10月的倒数第四天,读书会已接近尾声,有些事还在继续。我的节庆整理还在继续。做不到很快的节奏,但就是...

网友评论

      本文标题:CALayer--to be continued

      本文链接:https://www.haomeiwen.com/subject/nprtjttx.html