V2EX = way to explore
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
Veelian
V2EX  ›  iDev

微信拖动效果实现思路

  •  
  •   Veelian · 2013-11-14 17:29:48 +08:00 · 4079 次点击
    这是一个创建于 3787 天前的主题,其中的信息可能已经有所发展或是发生改变。
    微信的消息列表,往下拖动能够显示后面的微信logo,这两个view(或layer),怎么叠放来实现这种效果?
    12 条回复    1970-01-01 08:00:00 +08:00
    bighair
        1
    bighair  
       2013-11-14 18:12:20 +08:00
    logo 是在 self.view 上吧


    前面消息列表是 UITableView ,
    tableView_.backgroundView = nil;
    tableView_.backgroundColor = [UIColor clearColor];
    Veelian
        2
    Veelian  
    OP
       2013-11-15 15:38:59 +08:00
    @bighair 试过,不行。
    yellowV2ex
        3
    yellowV2ex  
       2013-11-15 15:42:21 +08:00
    tableview变透明底,然后tableview下面加个背景就好啦
    要用UIViewController
    Veelian
        4
    Veelian  
    OP
       2013-11-15 15:52:06 +08:00
    @yellowV2ex 我也是这么想的,可这样不行,你可以试下。
    bighair
        5
    bighair  
       2013-11-15 16:08:37 +08:00
    @Veelian 你应该是在 7 的模拟器试的吧~

    你需要这句

    self.automaticallyAdjustsScrollViewInsets = NO ; // 禁用 ScrollView 自动延伸到导航栏及状态栏
    bighair
        6
    bighair  
       2013-11-15 16:11:25 +08:00
    @Veelian

    对了,表视图的纵坐标也要从 64 开始, 如→ initWithFrame:CGRectMake(0, 64, 320, 568)

    因为在 7 里 滚动视图 默认有很大改变~ 默认延伸到了 导航栏 之下,为了体现毛玻璃的特性,所以就把 self.view 盖住了。
    gluttony
        7
    gluttony  
       2013-11-19 16:26:41 +08:00
    @Veelian 把消息列表页放在一个UIScrollView里,并且设置UIScrollView的属性 bounces = YES 和 alwaysBounceVertical = YES 。

    https://gist.github.com/gluttony/7542040
    Veelian
        8
    Veelian  
    OP
       2013-11-20 11:47:28 +08:00
    @gluttony thanks,还是不行,[_containerView addSubview:logoImageView]; 这样会让拖动_containerView的时候,logoImageView也跟着动。
    gluttony
        9
    gluttony  
       2013-11-20 12:50:12 +08:00
    @Veelian 修改了以下gist,这回可以了。

    http://gist.github.com/gluttony/7542040
    Veelian
        10
    Veelian  
    OP
       2013-11-20 14:16:24 +08:00
    @gluttony thanks,这些方法我都有试过,按照逻辑是这样的,但是实际效果却不行,你有把代码跑一下试试吗?
    gluttony
        11
    gluttony  
       2013-11-20 15:09:34 +08:00   ❤️ 2
    Veelian
        12
    Veelian  
    OP
       2013-11-20 15:30:04 +08:00
    @gluttony 就是它了,灰常感谢。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5479 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 01:35 · PVG 09:35 · LAX 18:35 · JFK 21:35
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.