Simple parallax header for UIScrollView

Related tags

UI MXParallaxHeader
Overview

MXParallaxHeader

CI Status Version Carthage compatible License Platform

⚠️ This project is no longer maintained, see #124 ⚠️

MXParallaxHeader is a simple header class for UIScrollView.

In addition, MXScrollView is a UIScrollView subclass with the ability to hook the vertical scroll from its subviews, this can be used to add a parallax header to complex view hierachy. Moreover, MXScrollViewController allows you to add a MXParallaxHeader to any kind of UIViewController.

UIScrollView MXScrollViewController
Demo Demo

Usage

If you want to try it, simply run:

pod try MXParallaxHeader
  • Adding a parallax header to a UIScrollView is straightforward, e.g:
Swift
let headerView = UIImageView()
headerView.image = UIImage(named: "success-baby")
headerView.contentMode = .scaleAspectFit

let scrollView = UIScrollView()
scrollView.parallaxHeader.view = headerView
scrollView.parallaxHeader.height = 150
scrollView.parallaxHeader.mode = .fill
scrollView.parallaxHeader.minimumHeight = 20
Objective-C
UIImageView *headerView = [UIImageView new];
headerView.image = [UIImage imageNamed:@"success-baby"];
headerView.contentMode = UIViewContentModeScaleAspectFill;

UIScrollView *scrollView = [UIScrollView new]; 
scrollView.parallaxHeader.view = headerView;
scrollView.parallaxHeader.height = 150;
scrollView.parallaxHeader.mode = MXParallaxHeaderModeFill;
scrollView.parallaxHeader.minimumHeight = 20;
  • The MXScrollViewController is a container with a child view controller that can be added programmatically or using the custom segue MXScrollViewControllerSegue.

  • Please check examples for Swift implementations.

Installation

Swift Package Manager

You can use Swift Package Manager directly within Xcode or add it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/mexp/MXParallaxHeader", .upToNextMajor(from: "1.1.0"))
]

CocoaPods

MXParallaxHeader is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "MXParallaxHeader"

Documentation

Documentation is available through CocoaDocs.

Author

Maxime Epain

Twitter

License

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

Comments
  • Weird width on MXParallaxHeader 1.1.0

    Weird width on MXParallaxHeader 1.1.0

    Issue Description

    • Weird width on MXParallaxHeader 1.1.0

    Environment Information

    • MXParallaxHeader 1.1.0
    • iPhone7 11.3.1, iPhone XR 13.2.2
    • Xcode 11.2.1

    Your Code

    let height: CGFloat = Constants.APPDELEGATE.cellSize.height + 50 + UIWindow.safeAreaTopInset
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            detailTableView.contentInsetAdjustmentBehavior = .never
            headerView = PostDetailCardView()
            detailTableView.parallaxHeader.view = headerView
            detailTableView.parallaxHeader.height = height
            detailTableView.parallaxHeader.mode = .fill
            detailTableView.parallaxHeader.minimumHeight = 0
    }
    

    Screenshot

    IMG_0058 by MXParallaxHeader 0.6.1

    IMG_0059 by MXParallaxHeader 1.1.0

    stale 
    opened by vkcldhkd 13
  • Exception 'NSRangeException' when unregistering KVO

    Exception 'NSRangeException' when unregistering KVO

    Crash on

    • (void)willMoveToSuperview:(UIView *)newSuperview { [self.superview removeObserver:self.parent forKeyPath:NSStringFromSelector(@selector(contentOffset)) context:kMXParallaxHeaderKVOContext]; }

    this is my error : Terminating app due to uncaught exception 'NSRangeException', reason: 'Cannot remove an observer <(null) 0x0> for the key path "contentOffset" from <MXParallaxView 0x1569c8860> because it is not registered as an observer.' *** First throw call stack: (0x180a42db0 0x1800a7f80 0x180a42cf8 0x1813590a8 0x181358b84 0x181358ac8 0x100ddaf80 0x185eb4014 0x185b994a0 0x185b9c924 0x181396cb0 0x1800c1ae8 0x1809209fc 0x1809f6bc0 0x180920c50 0x182208088 0x185c0a088 0x100281a58 0x1804be8b8) libc++abi.dylib: terminating with uncaught exception of type NSException

    bug 
    opened by YanSteph 13
  • UICollectionView dragging is not smooth

    UICollectionView dragging is not smooth

    Then MXScroll content is a UICollectionView. I have dragged the collectionView reducing the header space. And I drag the collectionView downwards , sometimes my action doesn't work. It is frozen except I drag the collection view upwards first.

    stale 
    opened by unash 12
  • Using MXParallaxHeader in UITableView with headers

    Using MXParallaxHeader in UITableView with headers

    Hi there, I'd like to use MXParallaxHeader in my UITableView, which worked great until I started adding section headers. The section header anchor point seems to be at the end of the ParallaxHeader, so the section headers stop there. Moreover the passed headers are moving above the HeaderView.

    Is there a way to change this behaviour or a workaround?

    Thanks in advance!

    mxissue

    stale 
    opened by iDevo 11
  • Floating Section Header not scrolling with tableView after using MXParallaxHeader for the tableHeaderView

    Floating Section Header not scrolling with tableView after using MXParallaxHeader for the tableHeaderView

    So I am facing this problem on my project. Somehow we must use UITableView with Plain Style and then dynamically adding table section header in to the tableView. And for the TableHeaderView of course I am using MXParallaxHeader. However, when I scroll the tableView up, my section header view got stock at the origin position while all cells are scrolling up. It is a very weird behavior I never seen before. I know #65 asked the same question but there is no a correct response. Please help. Thank you

    stale 
    opened by Tim77277 8
  • iOS 11 glitch with MXScrollViewController

    iOS 11 glitch with MXScrollViewController

    Hi, When I build my project with Xcode 9 / iOS11, a glitch appear when I scroll it. The same with Xcode 8 / iOS10 works great. This issue occur whith MXScrollViewController.

    With the MXScrollViewController demo, there is also a problem with the UIWebView when you scroll to top. Could you check please ?

    Don't hesitate to contact me.

    Thanks!

    stale 
    opened by Aurazion 8
  • SPM suppport

    SPM suppport

    Description

    Added Package.swift file

    Motivation and Context

    integrate this nice piece of code using SPM

    How Has This Been Tested?

    building it with xed . in repo folder to open the Package.swift "pseudo-project" with in Xcode

    Screenshots (if appropriate):

    Types of changes

    • [ ] Bug fix (non-breaking change which fixes an issue)
    • [x] New feature (non-breaking change which adds functionality)
    • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)

    Checklist:

    • [x] My code follows the code style of this project.
    • [x] My change requires a change to the documentation.
    • [x] I have updated the documentation accordingly.
    opened by kenji21 7
  • resize header height

    resize header height

    My header loads with a specific height, then I fetch the user data on server and load all informations about the user.

    I need to change the header size after all informations are ready.

    I tried to use self.segmentedPager.parallaxHeader.height = CGRectGetHeight(headerBoxView.bounds); but didn't work

    the CGRectGetHeight(headerBoxView.bounds returns the right height, but the header doesn't change

    [headerBoxView setNeedsLayout];
    self.segmentedPager.parallaxHeader.height = CGRectGetHeight(headerBoxView.bounds);
    [self.segmentedPager reloadData];
    [self.segmentedPager layoutIfNeeded];
    [self.view layoutIfNeeded];
    
    stale 
    opened by CavalcanteLeo 7
  • Bug in the interaction regarding the small part that is not hidden

    Bug in the interaction regarding the small part that is not hidden

    There are several bugs regarding gestures or interaction like:

    https://github.com/maxep/MXParallaxHeader/issues/17 https://github.com/maxep/MXParallaxHeader/issues/20

    The reason is because when we scroll a lot, the parallax contentView is outside screen and does not send taps to its subviews, even if they are displaced to be presented in the screen again.

    You can see that using Reveal: screen shot 2016-09-01 at 17 19 13

    If we swap parallax.contentView.frame.origin.y and parallax.view.frame.origin.y then it works, but of course that only works in Reveal. Doing that we will see how the components that are in the small part (defined by parallaxHeader.minimumHeight) would work again.

    I tried to modify the lib to do something like that, but no luck at the moment. Does anyone have any idea? This would make the tiny part interactive, which is important.

    opened by Ricardo1980 7
  • Troubles when add sections in UITableView

    Troubles when add sections in UITableView

    I have downloaded example project and just added sections in UITableView with simple title and when try scrolling section views freeze where they appear.

    Any suggestions?

    simulator screen shot 26 2016 20 50 49 simulator screen shot 26 2016 20 50 54

    opened by IgorBulyga 7
  • Pull to refresh not working

    Pull to refresh not working

    Hi @maxep Pull to refresh is not working along with parallax header. It tried setting bounce to false for my tableview which set the pull to refresh disabled.

    Please help how can we solve this.

    stale 
    opened by hardikamal 6
  • Fix SPM Usage in Xcode 12.5+

    Fix SPM Usage in Xcode 12.5+

    Description

    On Xcode 12.5, apparently the umbrella header generation logic changed, so this stopped working on my project because my project couldn't find MXScrollView anymore, when importing this lib using SPM. The problem was that the generated umbrella header didn't contain references to all the public headers. This PR aims to fix that.

    Motivation and Context

    How Has This Been Tested?

    It compiles on my project now 😄

    Before:

    import MXParallaxHeader
    …
    let scrollView = MXScrollView // Couldn't find reference to MXScrollView
    

    Now, the same code above compiles just fine.

    Types of changes

    • [x] Bug fix (non-breaking change which fixes an issue)
    • [ ] New feature (non-breaking change which adds functionality)
    • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)

    Checklist:

    • [x] My code follows the code style of this project.
    • [ ] My change requires a change to the documentation. - Nope
    • [ ] I have updated the documentation accordingly. - There's no need to update anything
    stale 
    opened by rogerluan 12
  • This project is no longer maintained

    This project is no longer maintained

    Hey,

    Unfortunately, I have decided to stop maintaining this project. This code is now an outdated implementation in Objective-C and I'm not giving it the attention it deserves.

    Please let me know if you want to become a contributor or feel free to share any alternative or forks in the comments of this issue.

    Thank you for your understanding!

    pinned 
    opened by maxep 4
Owner
Maxime Epain
iOS developer @discogs and several open source projects.
Maxime Epain
A custom stretchable header view for UIScrollView or any its subclasses with UIActivityIndicatorView and iPhone X safe area support for content reloading. Built for iOS 10 and later.

Arale A custom stretchable header view for UIScrollView or any its subclasses with UIActivityIndicatorView support for reloading your content. Built f

Putra Z. 43 Feb 4, 2022
Apple TV Parallax effect in Swift.

MPParallaxView Apple TV Parallax effect in Swift. Rotate view using touch or accelerometer. Usage To run the example project, clone the repo, and run

Droids On Roids 1.7k Jan 4, 2023
Scrollable UINavigationBar that follows the scrolling of a UIScrollView

A custom UINavigationController that enables the scrolling of the navigation bar alongside the scrolling of an observed content view Versioning notes

Andrea Mazzini 6.1k Dec 24, 2022
A container view that responds to scrolling of UIScrollView

FlexibleHeader A container view that responds to scrolling of UIScrollView. normal threshold FlexibleHeaderExecutantType Getting Started Progressive I

DongHee Kang 69 May 2, 2022
Creating a simple selectable tag view in SwiftUI is quite a challenge. here is a simple & elegant example of it.

SwiftUI TagView Creating a simple selectable tag view in SwiftUI is quite a challenge. here is a simple & elegant example of it. Usage: Just copy the

Ahmadreza 16 Dec 28, 2022
Simple battery shaped UIView

BatteryView Simple battery shaped UIView. Usage let batteryView = BatteryView(frame: smallRect) batteryView.level = 42 // anywhere in 0...100 batteryV

Yonat Sharon 50 Sep 19, 2022
A simple, customizable view for efficiently collecting country information in iOS apps.

CountryPickerView CountryPickerView is a simple, customizable view for selecting countries in iOS apps. You can clone/download the repository and run

Kizito Nwose 459 Dec 27, 2022
Swift based simple information view with pointed arrow.

InfoView View to show small text information blocks with arrow pointed to another view.In most cases it will be a button that was pressed. Example To

Anatoliy Voropay 60 Feb 4, 2022
🏞 A simple iOS photo and video browser with optional grid view, captions and selections written in Swift5.0

Introduction ?? MediaBrowser can display one or more images or videos by providing either UIImage objects, PHAsset objects, or URLs to library assets,

Kyle Yi 631 Dec 29, 2022
Simple selection dialog

SelectionDialog Simple selection dialog inspired from ios-custom-alertview Preview Requirements iOS 8.0+ Swift 3 Xcode 8.0 Installation CocoaPods use_

Lee Sun-Hyoup 117 Aug 5, 2022
Simple PhotoBrowser/Viewer inspired by facebook, twitter photo browsers written by swift

SKPhotoBrowser Simple PhotoBrowser/Viewer inspired by facebook, twitter photo browsers written by swift features Display one or more images by providi

keishi suzuki 2.4k Jan 6, 2023
Simple and highly customizable iOS tag list view, in Swift.

TagListView Simple and highly customizable iOS tag list view, in Swift. Supports Storyboard, Auto Layout, and @IBDesignable. Usage The most convenient

Ela Workshop 2.5k Jan 5, 2023
🍞 Toast for Swift - Toaster Android-like toast with very simple interface

Toaster Android-like toast with very simple interface. (formerly JLToast) Screenshots Features Queueing: Centralized toast center manages the toast qu

Suyeol Jeon 1.6k Jan 3, 2023
Stencil is a simple and powerful template language for Swift.

Stencil Stencil is a simple and powerful template language for Swift. It provides a syntax similar to Django and Mustache. If you're familiar with the

Stencil Project 2.2k Jan 4, 2023
Peanut is an orginizational application focusing on user customization whithin a simple interface.

Peanut Peanut is an organizational application focusing on user customization within a simple interface. Table of Contents User Features Architecture

Adam Herring 2 Mar 2, 2022
A Simple Camera App With Programmatic UI

CameraApp-ProgrammaticUI Hey there! This is a simple Camera Application that I and Sahab Alharbi worked on as part of Tuwaiq's iOS bootcamp projects.

null 0 Dec 4, 2021
📖 A simple, highly informative page view controller

TL;DR UIPageViewController done properly. ⭐️ Features Simplified data source management & enhanced delegation. Dynamically insert & remove pages. Infi

UI At Six 1.8k Dec 24, 2022
A replacement of default action sheet, but has very simple usage

KPActionSheet A replacement of default action sheet, but has very simple usage. Todo Add more custom affects and styles. Installation CocoaPods KPActi

Kenny 7 Jun 27, 2022
A simple and elegant UIKit for iOS.

HamsterUIKit A simple and elegant UIKit(Chart) for iOS, written in Swift. ?? Curve and bar Charts. ?? Protocols are designed based on UIKit(UITableVie

Howard Wang 30 Oct 2, 2022