Giter VIP home page Giter VIP logo

horseshoe7 / sopatternbgtableviewcontroller Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 0.0 256 KB

This Table View Controller allows you to provide a pattern image that scrolls with your content (originally designed for a TableView although could equally work with a UIScrollView) with the table view's content, which could have row heights that are not a multiple of your desired backgroundt tile size.

Objective-C 100.00%

sopatternbgtableviewcontroller's Introduction

SOPatternBGTableViewController

This View Controller allows you to provide a pattern image as a moveable background that scrolls with your content (e.g a UIScrollView or UITableView) with that scroll view's content, which (if a tableView) could have row heights that are not a multiple of your desired background tile size.

We see here that I have Table Cells in the foreground that have dynamic heights (their cells have a UIImageView as their backgroundView with no image loaded and backgroundColor set to [UIColor clearColor], with a colored contentView). The background tile pattern is one fixed image that populates the cells in this background table. The heights of those cells in the background are a multiple of the pattern image's height

Imgur

Installation and Usage

  • Import the SOPatternBGTableViewController folder into your project.
  • Subclass the SOPatternBGTableViewController and be sure to set the self.masterScrollView property in your loadView / NIB / Storyboard, OR before you call [super viewDidLoad]
  • The same applies for the self.backgroundPattern property although could likely be changed later. (Hasn't been really tested though)
  • Then use the class as you normally would use a UIViewController.

About this Implementation

So the idea here is to workaround a limitation in the UITableView (due to the otherwise awesome queuing system) if you have a background that should scroll with the content, but it's built from a tiled pattern and therefore not be part of the cell itself. If it's part of that table's background, it doesn't scroll. If you wanted it to scroll with the content, you'd have to ensure that all your row heights are a multiple of the pattern image's height. Sometimes this just isn't what you want.

So the idea is to have two scrollable view, where one is the slave of the other, and will resize itself according to the content. This view controller demonstrates that.

It should be that the masterScrollView can have dynamic height content, and backTable is a pattern of static row height that scrolls with it.

In your subclass you should ensure that the self.masterScrollView property is set in either loadView, in a NIB/Storyboard, or BEFORE you call [super viewDidLoad]. The same is generally true for the backgroundPattern property.

sopatternbgtableviewcontroller's People

Contributors

horseshoe7 avatar

Stargazers

sanghv avatar Ruslan avatar SuperFancy avatar Sergiy Gladkyy avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.