iOS 上如何实现排除某个 view 的 mask 效果? - V2EX
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
xhacker
V2EX    iDev

iOS 上如何实现排除某个 view 的 mask 效果?

  •  
  •   xhacker
    xhacker Jan 31, 2014 5328 views
    This topic created in 4507 days ago, the information mentioned may be changed or developed.
    大概就是 Clear 那样,点击一个 row 之后其他部分都变暗,除了这个 row 还是亮的。

    现有一个 table view,我也想实现点击一个 cell 后,除了这个 cell 的其他地方都变暗。试了以下两个方法,都不太理想。

    1. 给其他所有 cell 上加一个 mask 层。但 iOS 7 现在 cell 之间有 separator,而且还有 inset,所以还要改 separator 的颜色和 inset,总之动画各种不舒服。而且卡。

    2. 直接在 [UIApplication sharedApplication].keyWindow 上加上下两个 mask。但这样 cell 移动的时候 mask 没法随之移动,非常蛋疼。

    大家有什么主意么?
    18 replies    1970-01-01 08:00:00 +08:00
    i0xbean
        1
    i0xbean  
       Jan 31, 2014
    点击 cell 触发建立一个新的 window 过渡到上层,新 window 中有个『假 cell』处理后续操作。
    xhacker
        2
    xhacker  
    OP
       Jan 31, 2014
    @i0xbean: 我想同时实现在点击 cell 的时候把 cell 滚动到最上面,有什么好办法能让「假 cell」随之移动么?
    alexrezit
        3
    alexrezit  
       Jan 31, 2014
    我觉得亮的 cell 不是原来的 cell 吧...
    xhacker
        4
    xhacker  
    OP
       Jan 31, 2014
    @alexrezit: 如果是另外的 view,怎么能和 cell 非常好地同步滚到上面呢…
    alexrezit
        5
    alexrezit  
       Jan 31, 2014
    @xhacker
    不知道, 我都不记得 table view 怎么操作了. 自己写一个 transition 试试?
    icyalala
        6
    icyalala  
       Jan 31, 2014
    直接加到tableView上不行吗?
    PrideChung
        7
    PrideChung  
       Jan 31, 2014
    方案2,cell移动的时候调整mask不就行了
    so898
        8
    so898  
       Jan 31, 2014
    给UITableView加Mask啊,然后把UITabbar和UINavigationBar的mask也都加上不就完了……
    cameo
        9
    cameo  
       Jan 31, 2014
    方案1明显更自然。

    cell有没有mask,作为cell的一个属性写进model里,要加mask时修改model值然后[tableView reloadData]完事。各种卡很有可能是你的实现有问题,比如cell没做好复用。

    方案2仅仅从表现层做hack来实现,完全没有深入问题在model层次的本质,为了解决问题而解决问题,是非常糟糕的设计。
    xhacker
        10
    xhacker  
    OP
       Feb 1, 2014
    @so898: 怎么让某个 cell 不被 mask?
    xhacker
        11
    xhacker  
    OP
       Feb 1, 2014
    @cameo: cell 加上 mask,separator 的颜色还是不变的。而且 separator 的颜色好像不能在 animation block 里调整。我想要一个逐渐变黑的过程。
    xhacker
        12
    xhacker  
    OP
       Feb 1, 2014
    @icyalala: 怎么让某个 cell 不被 mask?
    @PrideChung: 怎么能动态监视 cell 的位置?
    so898
        13
    so898  
       Feb 1, 2014 via iPhone
    @xhacker 算高度……这种破事我经常干……
    xhacker
        14
    xhacker  
    OP
       Feb 1, 2014
    @so898: 那怎么跟着 cell 滚啊= =
    xhacker
        16
    xhacker  
    OP
       Feb 1, 2014
    @PrideChung: 我用 scrollToRowAtIndexPath:atScrollPosition:animated: 来把 row 滚动到最上面,不会调 scrollViewDidScroll:。
    so898
        17
    so898  
       Feb 1, 2014
    @xhacker 你把它添加到UITablView上面了,自然会跟着滚的啊
    xhacker
        18
    xhacker  
    OP
       Feb 2, 2014
    @so898: 有道理……我试试看。
    About     Help     Advertise     Blog     API     FAQ     Solana     912 Online   Highest 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 39ms UTC 21:23 PVG 05:23 LAX 14:23 JFK 17:23
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86