• [iOS基础控件


    A.功能
    1.上下可滚动的电台 2 x n 的图标集
    2.顶部半透明标题
    3.底部半透明功能按钮
     
    B.实现思路
    1.设置图标、启动画面
    Image(55)
     
     
    Image(56)
     
    2.拖入UIScrollView,设置背景色
    (1)设置contentSize, x=0阻止水平移动
     
    3.加入电台图标(6个)
     
    4.加入顶部标题和设置按钮,加入到总的View,不是UIScrollView
    (1)设置半透明
    (2)给UIScrollView顶部增加额外的滚动区域(不直接使用位置下移,是为了达到顶部标题区的穿透效果),区域和顶部标题区位置、尺寸一致
    (3)初始化UIScrollView设置一开始的滚动位置contentOffset,一开始不要上升到顶部标题区
    (4)状态栏高20个单位,注意标题和按钮位置
     1     // 取得最底端的Y值
     2     CGFloat maxY = CGRectGetMaxY(self.lastImage.frame);
     3    
     4     // 设置水平方向不可滚,垂直方向可滚动到最底端
     5     self.scrollView.contentSize = CGSizeMake(0, maxY);
     6    
     7     // 设置顶部、底部间隔
     8     self.scrollView.contentInset = UIEdgeInsetsMake(55, 0, 70, 0);
     9    
    10     // 设置初始滚动位置
    11     self.scrollView.contentOffset = CGPointMake(0, -55);
     
    Image(57)  
    Image(58)  Image(59)
     
    5.加入底部按钮
    (1)使用CGRectGetMaxY等方法得到底部的最低位置,以设置contentSize
     
    6.加入底部功能按钮区
     
    Image(60)
     
     
    主要代码
     1 //
     2 //  ViewController.m
     3 //  Radio
     4 //
     5 //  Created by hellovoidworld on 14/11/28.
     6 //  Copyright (c) 2014年 hellovoidworld. All rights reserved.
     7 //
     8 
     9 #import "ViewController.h"
    10 
    11 @interface ViewController ()
    12 @property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
    13 @property (weak, nonatomic) IBOutlet UIButton *lastImage;
    14 
    15 @end
    16 
    17 @implementation ViewController
    18 
    19 - (void)viewDidLoad {
    20     [super viewDidLoad];
    21     // Do any additional setup after loading the view, typically from a nib.
    22    
    23     [self initScrollView];
    24 }
    25 
    26 - (void)didReceiveMemoryWarning {
    27     [super didReceiveMemoryWarning];
    28     // Dispose of any resources that can be recreated.
    29 }
    30 
    31 - (void) initScrollView {
    32     // 取得最底端的Y值
    33     CGFloat maxY = CGRectGetMaxY(self.lastImage.frame);
    34    
    35     // 设置水平方向不可滚,垂直方向可滚动到最底端
    36     self.scrollView.contentSize = CGSizeMake(0, maxY);
    37    
    38     // 设置顶部、底部间隔
    39     self.scrollView.contentInset = UIEdgeInsetsMake(55, 0, 70, 0);
    40    
    41     // 设置初始滚动位置
    42     self.scrollView.contentOffset = CGPointMake(0, -55);
    43 }
    44 
    45 @end
     
     
  • 相关阅读:
    156
    More Effective C++ 条款24 了解virtual function,multiple inheritance,virtual base classes,runtime type identification的成本
    More Effective C++ 条款23 考虑使用其他程序库
    More Effective C++ 条款22 考虑以操作符复合形式(op=)取代其独身形式(op)
    More Effective C++ 条款21 利用重载技术避免隐式类型转换
    More Effective C++ 条款20 协助完成"返回值优化(RVO)"
    More Effective C++ 条款19 了解临时对象的来源
    More Effective C++ 条款18 分期摊还预期的成本
    More Effective C++ 条款17 考虑使用lazy evaluation(缓式评估)
    More Effective C++ 条款16 谨记80-20法则
  • 原文地址:https://www.cnblogs.com/hellovoidworld/p/4129823.html
Copyright © 2020-2023  润新知