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];
        }
    }
  • 相关阅读:
    【蓝桥杯/算法训练】Sticks 剪枝算法 (附胜利大逃亡)
    【蓝桥杯/基础练习】回文数、特殊的回文数
    【蓝桥杯/基础练习】十六进制转八进制
    交叉验证
    第一次写博客---交叉验证
    实验五
    汇编语言第二章
    实验四
    实验三
    实验二
  • 原文地址:https://www.cnblogs.com/yintingting/p/4689770.html
Copyright © 2011-2022 走看看