Giter Club home page Giter Club logo

apparallaxheader's Introduction

APParallaxHeader

This category makes it super easy to add a parallax header view to your scroll views. Other alternatives relies on subclassing of UIScrollView, UITableViewController or UITableView. Instead APParallaxHeader uses the Objective-C runtime to add the two following methods to UIScrollView without the need to do any subclassing.

- (void)addParallaxWithImage:(UIImage *)image andHeight:(CGFloat)height andShadow:(BOOL)shadow;
- (void)addParallaxWithImage:(UIImage *)image andHeight:(CGFloat)height;
- (void)addParallaxWithView:(UIView*)view andHeight:(CGFloat)height;

Demo

Demo

Installation

From CocoaPods

Add pod 'APParallaxHeader' to your Podfile (or pod 'APParallaxHeader', :head if you're feeling adventurous, and want to live on the edge).

Manually

Important note if your project doesn't use ARC: you must add the -fobjc-arc compiler flag to UIScrollView+ APParallaxHeader.m in Target Settings > Build Phases > Compile Sources.

  • Drag the APParallaxHeader/APParallaxHeader folder into your project.
  • #import UIScrollView+APParallaxHeader.h wherever you feel the need.

Usage

(see sample Xcode project in /Demo)

Adding Parallax image

[tableView addParallaxWithImage:[UIImage imageNamed:@"ImageName"] andHeight:160];

Adding Parallax custom view

Note: When adding a custom view. Either use APParallaxViewDelegate, auto layout constraints or contentMode to resize your custom view during scrolling.

UIView *customView = [[UIView alloc] init];
[customView setFrame:CGRectMake(0, 0, 320, 160)];
[self.tableView addParallaxWithView:customView andHeight:160];

[self.tableView.parallaxView setDelegate:self];

APParallaxViewDelegate

APParallaxViewDelegate will notify the delegate about resizing of the parallax view.

####Methods:####

  • - (void)parallaxView:(APParallaxView *)view willChangeFrame:(CGRect)frame
  • - (void)parallaxView:(APParallaxView *)view didChangeFrame:(CGRect)frame

ToDo

  • Ability to customize the drop shadow size, opacity, color etc.
  • Setting a minimum height
  • Setting contentMode of the imageView

Known issues

  • Section headers for tableviews with style UITableViewStylePlain will not be pinned as expected during scrolling.

Changelog

0.1.6

  • Re-added/fixed optional shadow implementation

0.1.5

  • Added delegate callbacks for APParallaxView resizes (APParallaxViewDelegate).

0.1.4

  • Ability to inititate with or without an inner shadow.
  • Ability to set a custom view as a parallax view.

0.1.3

  • Added an inner shadow

0.1.2

  • Initial release

Credits

APParallaxHeader is brought to you by Mathias Amnell at Apping AB. The code is inspired by Sam Vermette's work with SVPullToRefresh (especially the usage of objc/runtime.h to make it so easy to implement, without the need of subclassing).

License

APParallaxHeader is available under the MIT license. See the LICENSE file for more info.

apparallaxheader's People

Contributors

amnell avatar hoya avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

apparallaxheader's Issues

What if i wanna to replace UIImage with UIView ???

If I want to make an custom view and add it to the top of table using the same effect what i need to change ??

I'm tried to change the meathod that take UIImage to UIView & change the Implementation for APParallax UIImageView to UIView then try to pass view to method and add as supView , but no luck :(

UIView with an Image as a Subview breaks Parallax

I am using below code to add a UIView with an UIImageView inside, next I would like to add a scrollview instead. But when you add the Image as the subView of UIView the Parallax does not work.

    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 160)];
    [view setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];
    UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ParallaxImage"]];
    [imageView setFrame:CGRectMake(0, 0, self.view.frame.size.width, 160)];
    [imageView setContentMode:UIViewContentModeScaleAspectFill];
    [imageView setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];
    [view addSubview:imageView];
    [self.tableView addParallaxWithView:view andHeight:160];

Any ideas?
Thanks for a great control.

Image is not displaying (White blank space)?

I currently have a view controller embedded in a navigation view controller. I added a tableview in storyboard, and connected it to my view. I then added the following line to my viewDidLoad method: [self.menuTableView addParallaxWithImage:[UIImage imageNamed:@"ParallaxImage.jpg"] andHeight:160]; and imported the image, but all I get is a blank white space where the image should be. menuTableView is the tableView that I'm working with.

Any idea why it isn't loading the image? I imported the library using cocoapods and imported the header file into my viewcontroller.

screen shot 2013-05-22 at 11 08 04 pm

How to change the top view into full size after scroll down to some point?

I'm trying to change the top view to full size after the user scroll down some points. The method (void)scrollViewDidScroll:(CGPoint)contentOffset help me to get the scroll point, but I cannot get the table from here to change it y origin and automatically change the size of the top view.

Can you help me?

image does not resize when resizing view [solution included, please check in to master]

i am using the APParallaxHeader in a Modal View which is resizeable. i figured out that the image does not resize but the APParallaxView does. So, easy fix for that is to set the autoresizingMask of imageView to the following in line 196:

[self.imageView setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];

and also in line 189 set the autoresizingmask for self:

[self setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];

Problem with UIScrollView

When I use a UIScrollView for addParallaxWithView:

It doesn't scroll with the main view.

Any solution ?

UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0,0,320,160)];
scrollView.contentSize = CGSizeMake(320, 170);
scrollView.showsHorizontalScrollIndicator = YES;
scrollView.showsVerticalScrollIndicator = NO;
scrollView.pagingEnabled = true;
scrollView.scrollEnabled = true;
scrollView.backgroundColor = [UIColor blueColor];
scrollView.tag = 9999;
scrollView.delegate = self;


UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Rover.jpg"]];
[imageView setFrame:CGRectMake(0, 0, 320, 160)];
[imageView setContentMode:UIViewContentModeScaleAspectFill];
[scrollView addSubview:imageView];


[_collectionView addParallaxWithView:scrollView andHeight:160];

iPad Support

This library has support for iPad?
Some times it's not working with iPad
Image zoom not working properly in iPad.
Can anyone help in out?

iOS7: Parallax view is not visible when pushed from UISearchDisplayController

When I push my TableViewController (that has a ParallaxHeader) from the didSelectRowAtIndexPath method of my search results table view (that is using UISearchDisplayController) the ParallaxHeader is hidden. This only happens with iOS 7.
Pushing my TableViewController from a regular view controller, everything's fine. So it seems like it has something todo with the SearchDisplayController and iOS 7.

apparallexheader_problem

MyTableViewControllerWithParallax *myVC = [[MyTableViewControllerWithParallax alloc] init];
[self.navigationController pushViewController:myVC animated:YES];

scrollToRow not working probably

Hi,

if I add the ParallaxHeader, the default function scrollToRowAtIndexPath does not work probably anymore.

Do u know how can I fix that?

Add Padding

I use addParallaxWithView to a UIImageView

How can I add some padding on the top and bottom of the UIImageView and still get the parallax effect?

Glitch in scrolling while using it with TableView sections.

We are using APParallaxHeader at multiple places in our app so far it was working great but with a one particular table view which has various sections it's not doing great it feels a glitch in scrolling sometimes and while pulling down the header a black background shows up in the background of header bottom part.

NIB

Can you please add a version for nib (xib) usage?

On first load the image appears halfway down until you first scroll (either up or down) from a callback.

Example code:

func getPhoto(callback: (Array<AnyObject>) -> ()) {
    let urlPath: NSString = "some_rest_url"
    let url = NSURL(string: urlPath)

    let request = NSMutableURLRequest(URL: url)
    request.HTTPMethod = "GET"
    request.addValue("application/json", forHTTPHeaderField: "Accept")

    let session = NSURLSession(configuration: NSURLSessionConfiguration.defaultSessionConfiguration(), delegate: self, delegateQueue: NSOperationQueue.mainQueue())

    var dataTask = NSURLSessionDataTask()
    dataTask = session.dataTaskWithRequest(request) { (data, response, error) in
        if (error == nil) {
            callback(array)
        }
    }
    dataTask.resume()
}

override func viewDidLoad() {
    super.viewDidLoad()

    // Works fine here with any image.
    //let venueImage = UIImage(named: "bg")
    //self.tableView.addParallaxWithImage(venueImage, andHeight: 160)

    // Bug occurs here, when coming from callback.
    api.getPhoto() { (photos) in
        let photo = photos[0] as FSPhoto
        let data = NSData(contentsOfURL: NSURL.URLWithString("\(photo.prefix)300x300\(photo.suffix)"))
        let venueImage = UIImage(data: data)
        let venueImage = UIImage(named: venueImage)
        self.tableView.addParallaxWithImage(venueImage, andHeight: 160)
    }
}

First Load (from callback method):

Image of Problem

When scrolling for the first time (either up or down), the image appears where it should be.

The image appears properly otherwise if it's just a simple call within the viewDidLoad.

Image of Fixed

Adding Labels to the Header

I understand its not an issue, but maybe a feature for later updates. I feel that adding multiple labels would be very beneficial for this category to have.

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.