zoukankan      html  css  js  c++  java
  • 页面滑动悬停在某个控件(两种做法)

    - (void)viewDidLoad {
        [super viewDidLoad];
        
        UIScrollView *scrollView = [[UIScrollView alloc] init];
        scrollView.frame = self.view.bounds;
        scrollView.delegate = self;
        [scrollView addSubview:[[UISwitch alloc] init]];
        scrollView.contentSize = CGSizeMake(self.view.frame.size.width, 1500);
        scrollView.backgroundColor = [UIColor redColor];
        [self.view addSubview:scrollView];
        
        UIView *bar = [[UIView alloc] init];
        bar.frame = CGRectMake(0, 70, self.view.frame.size.width, 50);
        bar.backgroundColor = [[UIColor blueColor] colorWithAlphaComponent:0.5];
        [scrollView addSubview:bar];
        self.bar = bar;
    }
    
    #pragma mark - <UIScrollViewDelegate>
    - (void)scrollViewDidScroll:(UIScrollView *)scrollView
    {
        if (scrollView.contentOffset.y >= 70) {
    //        self.bar.frame = CGRectMake(0, 0, self.view.frame.size.width, 50);
    //        [self.view addSubview:self.bar];
            self.bar.frame = CGRectMake(0, scrollView.contentOffset.y, self.view.frame.size.width, 50);
        } else {
    //        self.bar.frame = CGRectMake(0, 70, self.view.frame.size.width, 50);
    //        [scrollView addSubview:self.bar];
        }
    }
  • 相关阅读:
    JSP使用JDBC ODBC 实例
    Gradle templates 的使用
    Java 中使用Jackson反序列化
    Java getResourceAsStream返回为空的问题
    MVC 学习随笔(一)
    分区信息查看
    关于线程 wait notify sleep
    synchronized与Lock
    java类初始化
    oracle sql 执行原理
  • 原文地址:https://www.cnblogs.com/yintingting/p/4689770.html
Copyright © 2011-2022 走看看