-
Notifications
You must be signed in to change notification settings - Fork 34
Changes made as you requested. #16
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
Open
thihaaung6245
wants to merge
1
commit into
azurechen:master
Choose a base branch
from
thihaaung6245:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,243 @@ | ||
| ACTabScrollView | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you copy a README file here? |
||
| =============== | ||
|
|
||
| [](http://cocoapods.org/pods/ACTabScrollView) | ||
| [](http://cocoapods.org/pods/ACTabScrollView) | ||
| [](https://developer.apple.com/ios/) | ||
| [](https://developer.apple.com/swift/) | ||
| [](https://developer.apple.com/reference/objectivec) | ||
| [](https://github.com/azurechen/ACTabScrollView/blob/master/LICENSE.md) | ||
|
|
||
|
|
||
|
|
||
| A fancy `Menu` and `Pager` UI extends `UIScrollView` with elegant, smooth and synchronized scrolling `tabs`. | ||
|
|
||
| DEMO | ||
| ---- | ||
|
|
||
| <img src="./Screenshots/demo-1.gif" width = "288" alt="Demo" /> | ||
| <img src="./Screenshots/demo-2.gif" width = "288" alt="Demo" /> | ||
| <img src="./Screenshots/demo-3.gif" width = "288" alt="Demo" /> | ||
|
|
||
| User can interact with the UI by some different gestures. The `tabs` and `pages` will always scroll `synchronously`. | ||
|
|
||
| * `Swipe` pages normally | ||
| * `Drag` tabs can quickly move pages | ||
| * `Click` a tab to change to that page | ||
|
|
||
| You can also use `changePageToIndex` method to scroll pages programmatically. | ||
|
|
||
| Usage | ||
| ----- | ||
|
|
||
| ###Add an Object of `ACTabScrollView` | ||
|
|
||
| Drag a `UIView` object onto the Interface Builder and set the `Class` to extends `ACTabScrollView ` in `XIB` or `Storyboard`. | ||
|
|
||
| <img src="./Screenshots/usage-1.png" width = "800" alt="Demo" /> | ||
|
|
||
| You can also set properties at `Interface Builder`. | ||
|
|
||
| And remember to declare the `IBOutlet`. | ||
|
|
||
| ```swift | ||
| @IBOutlet weak var tabScrollView: ACTabScrollView! | ||
| ``` | ||
|
|
||
| ###Set Properties | ||
|
|
||
| All the following properties are `optional`. It provides more flexibility to customize. But it will be fine if you don't change any property. | ||
|
|
||
| ```swift | ||
| override func viewDidLoad() { | ||
| super.viewDidLoad() | ||
|
|
||
| // all the following properties are optional | ||
| tabScrollView.defaultPage = 3 | ||
| tabScrollView.arrowIndicator = true | ||
| tabScrollView.tabSectionHeight = 40 | ||
| tabScrollView.tabSectionBackgroundColor = UIColor.whiteColor() | ||
| tabScrollView.contentSectionBackgroundColor = UIColor.whiteColor() | ||
| tabScrollView.tabGradient = true | ||
| tabScrollView.pagingEnabled = true | ||
| tabScrollView.cachedPageLimit = 3 | ||
|
|
||
| // for changing arrow to upside direction | ||
| //tabScrollView.isUpsideArrowIndicator = true | ||
|
|
||
| // for changing background color of arrow view | ||
| //tabScrollView.arrowBackgroundColor = UIColor.white | ||
|
|
||
| // for changing arrow width and height too | ||
| //tabScrollView.arrowWidth = 30 | ||
| //tabScrollView.arrowHeight = 10 | ||
|
|
||
| ... | ||
| } | ||
| ``` | ||
|
|
||
| ###Delegate and DataSource | ||
|
|
||
| Set `Delegate` and `DataSource` first in `viewDidLoad()`, the usage is similar to `UITableView`. | ||
|
|
||
| ```swift | ||
| override func viewDidLoad() { | ||
| ... | ||
|
|
||
| tabScrollView.delegate = self | ||
| tabScrollView.dataSource = self | ||
|
|
||
| ... | ||
| } | ||
| ``` | ||
|
|
||
| Prepare all the content views in `viewDidLoad()` may be a good idea. We had better not create the content view at each page change because it may cause performance issues. | ||
|
|
||
| ```swift | ||
| override func viewDidLoad() { | ||
| ... | ||
|
|
||
| // create content views from storyboard | ||
| let storyboard = UIStoryboard(name: "Main", bundle: NSBundle.mainBundle()) | ||
| for i in 0 ..< /* number of pages */ { | ||
| let vc = storyboard.instantiateViewControllerWithIdentifier("ContentViewController") as! ContentViewController | ||
|
|
||
| /* set somethings for vc */ | ||
|
|
||
| addChildViewController(vc) // don't forget, it's very important | ||
| contentViews.append(vc.view) | ||
| } | ||
|
|
||
| ... | ||
| } | ||
| ``` | ||
|
|
||
| And implement methods | ||
|
|
||
| ```swift | ||
| // MARK: ACTabScrollViewDelegate | ||
| func tabScrollView(tabScrollView: ACTabScrollView, didChangePageTo index: Int) { | ||
| print(index) | ||
| } | ||
|
|
||
| func tabScrollView(tabScrollView: ACTabScrollView, didScrollPageTo index: Int) { | ||
| } | ||
|
|
||
| // MARK: ACTabScrollViewDataSource | ||
| func numberOfPagesInTabScrollView(tabScrollView: ACTabScrollView) -> Int { | ||
| return /* number of pages */ | ||
| } | ||
|
|
||
| func tabScrollView(tabScrollView: ACTabScrollView, tabViewForPageAtIndex index: Int) -> UIView { | ||
| // create a label | ||
| let label = UILabel() | ||
| label.text = /* tab title at {index} */ | ||
| label.textAlignment = .Center | ||
|
|
||
| // if the size of your tab is not fixed, you can adjust the size by the following way. | ||
| label.sizeToFit() // resize the label to the size of content | ||
| label.frame.size = CGSize( | ||
| width: label.frame.size.width + 28, | ||
| height: label.frame.size.height + 36) // add some paddings | ||
|
|
||
| return label | ||
| } | ||
|
|
||
| func tabScrollView(tabScrollView: ACTabScrollView, contentViewForPageAtIndex index: Int) -> UIView { | ||
| return contentViews[index] | ||
| } | ||
| ``` | ||
|
|
||
| The usage tutorial is finished, you can see more details and example at `ACTabScrollView/NewsViewController.swift` | ||
|
|
||
| ###Using `ACTabScrollView` in `Objective-C` Project | ||
|
|
||
| It is very very easy if you use the newest version of Xcode. | ||
|
|
||
| First, import the automatically generated header `ACTabScrollView-Swift.h` in your `.m` file. | ||
|
|
||
| ```objective-c | ||
| #import "ACTabScrollView-Swift.h" | ||
| ``` | ||
|
|
||
| This header is generated automatically, you don't need to change any setting. | ||
|
|
||
| And try to use `ACTabScrollView` in your `ViewController.m` | ||
|
|
||
| ```objective-c | ||
| #import "ViewController.h" | ||
| #import "ACTabScrollView-Swift.h" | ||
|
|
||
| @interface ViewController () | ||
| @end | ||
|
|
||
| @implementation ViewController | ||
|
|
||
| - (void)viewDidLoad { | ||
| [super viewDidLoad]; | ||
|
|
||
| ACTabScrollView *tabScrollView = [[ACTabScrollView alloc] init]; | ||
|
|
||
| tabScrollView.defaultPage = 3; | ||
| tabScrollView.arrowIndicator = true; | ||
| } | ||
|
|
||
| @end | ||
| ``` | ||
| Enjoy `ACTabScrollView` in your Objective-C project. 🎉 | ||
| How to Install | ||
| -------------- | ||
| ###CocoaPods | ||
| If you didn't use [CocoaPods](http://cocoapods.org) before, install it first. | ||
| ```bash | ||
| $ gem install cocoapods | ||
| $ pod setup | ||
| ``` | ||
|
|
||
| Create a file named `Podfile` in your project folder if this file doesn't exist. And append the following line into your `Podfile`. | ||
|
|
||
| ```bash | ||
| pod 'ACTabScrollView', :git => 'https://github.com/azurechen/ACTabScrollView.git' | ||
| ``` | ||
|
|
||
| Then, run this command. 🎉 | ||
|
|
||
| ```bash | ||
| $ pod install | ||
| ``` | ||
|
|
||
| ###Manual | ||
|
|
||
| Drag these two files into your project. | ||
|
|
||
| * `Sources/ACTabScrollView.swift` | ||
| * `Sources/ACTabScrollView+Protocol.swift` | ||
|
|
||
| And you can use `ACTabScrollView`. 🎉 | ||
|
|
||
| Inspiration | ||
| ----------- | ||
|
|
||
| The [Stackoverflow Question](http://stackoverflow.com/questions/26831662/creation-of-a-horizontal-infinite-scrolling-menu-bar-in-ios) inspired me to create this repo. Although `ACTabScrollView` does not implement all the features it mentions, such as `Infinite Scrolling`, I will keep to implement that. But the idea give me a motivation to do something, and brought `ACTabScrollView` here. | ||
|
|
||
| I use the UI from that question as examples in this project, because that is the best sample to show this concept, and only as an example. I always want to know what the app is but I still don't figure out. | ||
|
|
||
| If you create the app and you don't like me to use it as an example. Contact me and I will immediately remove that. Or I can mention you and your work at README and example files. Thank you very much! | ||
|
|
||
| License | ||
| ------- | ||
|
|
||
| The MIT License (MIT) | ||
|
|
||
| Copyright (c) 2016 Azure Chen | ||
|
|
||
| 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. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.DS_Store should be a default ignored item. You don't need to add this line in .gitignore file.
If you still cannot ignore that. You may check this
http://stackoverflow.com/questions/18393498/gitignore-all-the-ds-store-files-in-every-folder-and-subfolder