iOS 开发实用技术导航
NSHipster 中文版
› http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
› http://www.cocos2d-iphone.org/
CocoaPods
› http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
› http://code.google.com/mobile/analytics/
WWDC
› https://developer.apple.com/wwdc/
Design Guides and Resources
› https://developer.apple.com/design/
Transcripts of WWDC sessions
› http://asciiwwdc.com
Cocoa with Love
› http://cocoawithlove.com/
Cocoa Dev Central
› http://cocoadevcentral.com/
NSHipster
› http://nshipster.com/
Style Guides
› Google Objective-C Style Guide
› NYTimes Objective-C Style Guide
Useful Tools and Services
› Charles Web Debugging Proxy
› Smore
Galvin
V2EX  ›  iDev

关于 ios 渐变的一些疑问

  •  
  •   Galvin · Apr 12, 2015 · 4377 views
    This topic created in 4225 days ago, the information mentioned may be changed or developed.
    看到qq音乐和网易云音乐的歌词显示的时候,顶部的歌词和底部的歌词都有一个渐变的效果,我想问下他们是怎么实现的
    图片
    12 replies  •  2015-04-14 11:27:56 +08:00
    Galvin
    Galvin
    OP
    Apr 12, 2015
    1
    求各路大神解答啊T_T
    thuai
    thuai
    Apr 12, 2015
    2
    最简单的做法,顶部和底部都用个半透的mask,不可以做到么?
    Madimo
    Madimo
    Apr 12, 2015 via iPhone
    3
    实现起来很简单,主要是用 CALayer 的 mask 属性以及 CAGradientLayer,手机码字不方便具体 Google 吧
    Galvin
    Galvin
    OP
    Apr 13, 2015
    4
    @thuai @Madimo 但是不透名的那一边呢?CAGradienLayer不是只能给颜色的数组吗?
    Galvin
    Galvin
    OP
    Apr 13, 2015
    5
    @Madimo @thuai 噢~我知道了。。。误入歧途
    wezzard
    wezzard
    Apr 13, 2015
    6
    CALayer 都不用,現在 UIView 有了 maskView 這個 property 之後可以直接才 UIKit 這一層完成。
    krafttuc
    krafttuc
    Apr 13, 2015
    7
    UIVisualEffectView
    Galvin
    Galvin
    OP
    Apr 13, 2015
    8
    @krafttuc UIVisualEffectView是ios8才支持的吧?
    Galvin
    Galvin
    OP
    Apr 13, 2015
    9
    @wezzard 能具体说说怎么实现吗?~目前我的做法是截上下两个部分的图,然后加CAGradientLayer,然后设置mask
    wezzard
    wezzard
    Apr 14, 2015
    10
    @Galvin 我沒具體實現過,因爲我發現以我接觸的需求但凡碰到要漸變的,就要進入 CoreAnimation 這個 tech stack了,我看了下 API,你準備一張上下有不透明漸變,中間是透明的PNG圖片然後 init 一個 UIImageView 出來再設置 maskView 應該就可以了。另外這個也是 iOS 8 特性。 UIVisualEffectView 是背後的 blurring 特效,網易的這個特效很可能是他們自己寫的,因爲要兼容 iOS 7。
    kobe1941
    kobe1941
    Apr 14, 2015
    11
    跑个题啊,这个歌词显示目测都是用tableView直接一行歌词一个tableviewcell就实现啦?
    Galvin
    Galvin
    OP
    Apr 14, 2015
    12
    @kobe1941 我觉得是~
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1278 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 57ms · UTC 21:40 · PVG 05:40 · LAX 13:40 · JFK 16:40
    ♥ Do have faith in what you're doing.