Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix crash when dealloc happens before viewWillAppear #20

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
19 changes: 19 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate

182 changes: 6 additions & 176 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# SLPagingView
[![Build Status](https://travis-ci.org/StefanLage/SLPagingView.svg?branch=master)](https://travis-ci.org/StefanLage/SLPagingView)
[![Version](https://img.shields.io/cocoapods/v/SLPagingView.svg?style=flat)](http://cocoadocs.org/docsets/SLPagingView)
[![License](https://img.shields.io/cocoapods/l/SLPagingView.svg?style=flat)](http://cocoadocs.org/docsets/SLPagingView)

A navigation bar system allowing to do a Tinder like or Twitter like.

Expand All @@ -10,181 +7,14 @@ A navigation bar system allowing to do a Tinder like or Twitter like.
<img src="Demos/TwitterLike/twitter.gif" algin="right" height="440" width="250" style="margin-left:50px;">
</div>

## Requirements
## Fork Changes

* iOS 7.0+
* ARC
* View Controller Containment
* Full screen (UIViewControllers show behind translucent bar)

## Installation
## TODO

### CocoaPods

[CocosPods](http://cocosPods.org) is the recommended method to install SLPagingView.

Add the following line to your Podfile:

```ruby
pod 'SLPagingView'
```

And run
```ruby
pod install
```

### Manual

Import SLPagingView folder into your project.


## How to use

Easy to implement:

```` objective-c

// Make views for the navigation bar
UIImage *img1 = [UIImage imageNamed:@"gear"];
img1 = [img1 imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];

UIImage *img2 = [UIImage imageNamed:@"profile"];
img2 = [img2 imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];

UIImage *img3 = [UIImage imageNamed:@"chat"];
img3 = [img3 imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];

NSArray *titles = @[[[UIImageView alloc] initWithImage:img1], [[UIImageView alloc] initWithImage:img2], [[UIImageView alloc] initWithImage:img3]];
NSArray *views = @[[self viewWithBackground:orange], [self viewWithBackground:[UIColor yellowColor]], [self viewWithBackground:gray]];

SLPagingViewController *pageViewController = [[SLPagingViewController alloc] initWithNavBarItems:titles
navBarBackground:[UIColor whiteColor]
views:views
showPageControl:NO];

````

Then you can make your own behaviors:

````objective-c

// Tinder Like
pageViewController.pagingViewMovingRedefine = ^(UIScrollView *scrollView, NSArray *subviews){
int i = 0;
for(UIImageView *v in subviews){
UIColor *c = gray;
if(v.frame.origin.x > 45
&& v.frame.origin.x < 145)
// Left part
c = [self gradient:v.frame.origin.x
top:46
bottom:144
init:orange
goal:gray];
else if(v.frame.origin.x > 145
&& v.frame.origin.x < 245)
// Right part
c = [self gradient:v.frame.origin.x
top:146
bottom:244
init:gray
goal:orange];
else if(v.frame.origin.x == 145)
c = orange;
v.tintColor= c;
i++;
}
};

````

##Other sample

Twitter like behaviors

````objective-c

// Twitter Like
pageViewController.pagingViewMovingRedefine = ^(UIScrollView *scrollView, NSArray *subviews){
CGFloat xOffset = scrollView.contentOffset.x;
int i = 0;
for(UILabel *v in subviews){
CGFloat alpha = 0.0;
if(v.frame.origin.x < 145)
alpha = 1 - (xOffset - i*320) / 320;
else if(v.frame.origin.x >145)
alpha=(xOffset - i*320) / 320 + 1;
else if(v.frame.origin.x == 140)
alpha = 1.0;
i++;
v.alpha = alpha;
}
};
````

##API

###Set current page

If you want to changed the default page control index (or whatever) you can do it calling:

````objective-c

-(void)setCurrentIndex:(NSInteger)index animated:(BOOL)animated;
````

###Navigation items style

<img src="Demos/TinderLike/navigation_style.gif" height="440" width="250" style="margin-left:50px;">

You can easily customized the navigation items setting up:


````objective-c

@property (nonatomic) SLNavigationSideItemsStyle navigationSideItemsStyle;
````


By using one of these values:


````objective-c

typedef NS_ENUM(NSInteger, SLNavigationSideItemsStyle) {
SLNavigationSideItemsStyleOnBounds,
SLNavigationSideItemsStyleClose,
SLNavigationSideItemsStyleNormal,
SLNavigationSideItemsStyleFar,
SLNavigationSideItemsStyleDefault,
SLNavigationSideItemsStyleCloseToEachOne
};
````

###Set navigation bar's background color

You can update the background color of the navigation bar using the following method:

````objective-c

setNavigationBarColor:(UIColor*) color;
````

##Storyboard support

This class can be implemented using Storyboard.
You need to set all identifiers of the segues linked to your SLPagingViewController respecting this syntax:
` sl_X where X ∈ [0..N] `.

X corresponding to the index of the view, start from 0 and it works in ascending order.

![segue](Demos/TinderStoryboard/segue_params.png)

You can find an example "TinderStoryboard" for more informations.

###Set navigation bar's background color
To set up the navigation bar's background color from the storyboard, you just need to it like all navigation bar.

![segue](Demos/TinderStoryboard/navigation_bar_color.png)
* Make custom bar view part of the navigation item

##License
Available under MIT license, please read LICENSE for more informations.
Available under MIT license, please read LICENSE for more information.
6 changes: 3 additions & 3 deletions SLPagingView.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ Pod::Spec.new do |s|
s.name = 'SLPagingView'
s.version = '0.0.5'
s.summary = 'Navigation bar system allowing to do a Tinder like or Twitter like'
s.homepage = 'https://github.com/StefanLage/SLPagingView'
s.homepage = 'https://github.com/ankorko/SLPagingView'
s.license = 'MIT'
s.author = { 'StefanLage' => 'lagestfan@gmail.com' }
s.source = { :git => 'https://github.com/StefanLage/SLPagingView.git', :tag => "#{s.version}" }
s.author = { 'ankorko' => 'ankorko@gmail.com' }
s.source = { :git => 'https://github.com/ankorko/SLPagingView.git', :tag => "#{s.version}" }
s.source_files = 'SLPagingView/**/*.{h,m}'
s.requires_arc = true
s.platform = :ios, '7.0'
Expand Down
9 changes: 8 additions & 1 deletion SLPagingView/SLPagingViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,17 @@ typedef void(^SLPagingViewDidChanged)(NSInteger currentPage);
* @param currentPage
*/
@property (nonatomic, copy) SLPagingViewDidChanged didChangedPage;

/*
* Contains all child view controllers
* if initialized with controlles not views
*/
@property (nonatomic, strong) NSMutableDictionary *viewControllersDict;

/*
* Contains all views displayed
*/
@property (nonatomic, strong) NSMutableDictionary *viewControllers;
@property (nonatomic, strong) NSMutableDictionary *viewsDict;
/*
* Tint color of the page control
*/
Expand Down
Loading