• Stars
    star
    162
  • Rank 231,060 (Top 5 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 7 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

便于构建 Header 悬停效果

banner

Description

BannerHoverView is made to construct a special view controller layout. This layout is like the screen shot demo. (A header can scroll up and hover in the screen.) I think it is a common layout and I make the header hovered view independent.

So, quick to build hover view by BannerHoverView in iOS development.

Screenshot

img

Usage

1. Import BannerHoverView

Please refer to Install.

2. Definition Derived View

It's like the SampleView below:

class SampleView: BannerHoverView {
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        self.setScrollAction { (view, offset) in
            // offset - distance percent
        }
        
        self.setTopAction { (view) in
            // scroll top callback
        }
        
        self.setBottomAction { (view) in
            // scroll bottom callback
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

3. Use In ViewController

Property

var tableView: UITableView!
var bannerHoverView: SampleView!

Init properties and KVO setting

// TableView Initial
tableView = UITableView.init(frame: view.bounds, style: .grouped)
tableView.dataSource = self
tableView.delegate = self

// BannerHoverView Initial
bannerHoverView = SampleView.init(frame: CGRect.init(x: 0, y: 0, width: view.frame.size.width, height: 280))
// Hover Height(Remaining part when BannerHoverView arrived at the top position)
bannerHoverView.top = 65
// Scroll Property Setting
bannerHoverView.headerScrollView = tableView

// Add Observer
tableView.addObserver(bannerHoverView, forKeyPath: "contentOffset", options: NSKeyValueObservingOptions.new, context: nil)
        
view.addSubview(tableView)
view.addSubview(bannerHoverView)

Delete Observer in ViewController

deinit {
    tableView.removeObserver(bannerHoverView, forKeyPath: "contentOffset")
}

Install

1. Cocoapods

pod 'BannerHoverView', '~> 0.0.1'

And you will get the BannerHoverView.swift file. 😎

2. Copy the source code in you project

You can copy the BannerHoverView folder and its source file BannerHoverView.swift in your project.

MIT License

Copyright (c) 2017 Desgard_Duan

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

More Repositories

1

iOS-Source-Probe

🔎 iOS 源码探求系列
Shell
911
star
2

DGDownloaderButton

Download Water Animation
Objective-C
229
star
3

DGExpandMenuButton

Spring Effect To Show Button Menu.
Objective-C
173
star
4

DGThumbUpButton

DGThumbUpButton---有动画的点赞按钮
Objective-C
162
star
5

DGAdLaunchView

An iOS Launch Advertising View--登录页广告
Objective-C
79
star
6

WeCheat

基于 MonkeyDev 对 WeChat 的个人扩展
Objective-C
73
star
7

DGPopUpViewController

DGPopUpViewController---卡片式弹出窗口
Objective-C
67
star
8

DGSlimeView

DGSlimeView--模仿QQ消息小红点动画及粒子爆炸动效
Objective-C
64
star
9

DGCuteHelper

A helper Class to achieve adhesive Bond Effect between two UIView.
Objective-C
33
star
10

DGGooeySlideMenu

DGGooeySlideMenu---模仿skype照相按钮弹出菜单弹簧效果
Objective-C
24
star
11

LearningEveryDay

每天学习打卡
8
star
12

wechat-hc-helper

冬瓜群微信机器人🤖️
Python
8
star
13

desgard.github.com

Guardia · 瓜地
HTML
8
star
14

Gua-Vim

Personal vim configuration
Vim Script
7
star
15

leetmonster

JavaScript
7
star
16

SwiftGG-Translation-Demo

The Demo Code For My Translation In SwiftGG
Swift
6
star
17

swiftui-designcode-demo

DesignCode SwiftUI 视频学习
Swift
6
star
18

JianshuMarkdownParser.py

自己做的小脚本,从简书上将文章爬成krandom引擎md格式
Python
5
star
19

Shanbei-Homework

Objective-C
5
star
20

CameraDemo

The camera app effect demo by GPUImage.
Swift
5
star
21

INoteBook

基于 Gitbook 的个人笔记自动化发布 pages 的 shell脚本
HTML
4
star
22

Compiler

Swift
4
star
23

DGPanCollectionView

可拖动cell的Collection,不通过CollectionController实现
Swift
4
star
24

Panda-Run

Running ! Panda!!
Swift
4
star
25

learning-in-shiyanlou.com

Learning Programming in shiyanlou.com.
Python
4
star
26

RAC-Study-Note

3
star
27

Letchat

Objective-C
3
star
28

ARM64-step

Assembly
2
star
29

srtp-for-Zhou

This project is the Zhou's SRTP project!
Objective-C
2
star
30

HackSwjtuXZ

亲们好好玩。
JavaScript
2
star
31

nota

个人笔记同步仓库
Jupyter Notebook
2
star
32

Repobot

shiyanlou.com 周报自动化生成脚本
Python
2
star
33

macho-dumper

Mach-O dump tools. To analysis the Apple Mach-O binary file
C
2
star
34

algo

Ruby
2
star
35

gua-bk

JavaScript
2
star
36

react-native-calculator

JavaScript
1
star
37

ReadIt

Java
1
star
38

Flowercat

1
star
39

Jekyll-Score

CSS
1
star
40

shell

Common shell Script
Shell
1
star
41

Guanja

Python
1
star
42

WechatGptBot

TypeScript
1
star
43

DissCode-FE

DissCode 前端
Vue
1
star
44

Guajira

http://life.desgard.com
CSS
1
star
45

Desgarpy-Bird

冬瓜像素鸟
Swift
1
star
46

Guardia-Flask

Python
1
star
47

react-native-tools

1
star
48

Learning-Design-Patterns

To Learn Design Patterns in iOS, by using Objective-C
Objective-C
1
star
49

Careless

Swift
1
star
50

img

1
star
51

swjtu-pyscraper

Test Flask and scraper by python.
Python
1
star
52

Beacon-Flask

The production of Echo team in the Best Developer Competition of iQiYi.
Python
1
star