diff --git a/.gitignore b/.gitignore
index 9724b3c..9e4cdf9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,6 @@
+# OSX
+.DS_Store
+
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
diff --git a/ACTabScrollView/Images.xcassets/README.md b/ACTabScrollView/Images.xcassets/README.md
new file mode 100644
index 0000000..0fa9aa6
--- /dev/null
+++ b/ACTabScrollView/Images.xcassets/README.md
@@ -0,0 +1,243 @@
+ACTabScrollView
+===============
+
+[](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
+----
+
+
+
+
+
+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`.
+
+
+
+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.
diff --git a/Sources/ACTabScrollView.swift b/Sources/ACTabScrollView.swift
index daa12eb..bdda431 100644
--- a/Sources/ACTabScrollView.swift
+++ b/Sources/ACTabScrollView.swift
@@ -3,9 +3,14 @@
// ACTabScrollView
//
// Created by AzureChen on 2015/8/19.
+// Edited by Thiha Aung on 2017/4/30.
// Copyright (c) 2015 AzureChen. All rights reserved.
//
+// Contributed by Thiha Aung on 2017/5/8
+// 1. Added implementations for upside arrow direction
+// 2. Added some inspectable to configure arrowView
+
// TODO:
// 1. Performace improvement
// 2. Test reloadData function
@@ -13,6 +18,9 @@
// 4. Bottom line or shadow
// 5. Support Carthage
+// ADDED:
+// 1. Set arrow item to up position
+
import UIKit
@IBDesignable
@@ -24,13 +32,24 @@ open class ACTabScrollView: UIView, UIScrollViewDelegate {
@IBInspectable open var tabSectionBackgroundColor: UIColor = UIColor.white
@IBInspectable open var contentSectionBackgroundColor: UIColor = UIColor.white
@IBInspectable open var tabGradient: Bool = true
- @IBInspectable open var arrowIndicator: Bool = false
@IBInspectable open var pagingEnabled: Bool = true {
didSet {
contentSectionScrollView.isPagingEnabled = pagingEnabled
}
}
@IBInspectable open var cachedPageLimit: Int = 3
+ @IBInspectable open var arrowIndicator: Bool = false
+<<<<<<< HEAD
+ @IBInspectable open var isUpsideArrowIndicator : Bool = false
+ @IBInspectable open var arrowBackgroundColor: UIColor = UIColor.white
+ @IBInspectable open var arrowWidth : CGFloat = 30
+ @IBInspectable open var arrowHeight : CGFloat = 10
+=======
+ @IBInspectable open var upsideArrowDirection : Bool = true
+ @IBInspectable open var arrowBackgroundColor: UIColor = UIColor.white
+ @IBInspectable open var arrowWidth : CGFloat = 12
+ @IBInspectable open var arrowHeight : CGFloat = 7
+>>>>>>> 4bcac438ac34da53f3e7bd74ab50f7d6bca4f663
open var delegate: ACTabScrollViewDelegate?
open var dataSource: ACTabScrollViewDataSource?
@@ -91,7 +110,7 @@ open class ACTabScrollView: UIView, UIScrollViewDelegate {
// init views
tabSectionScrollView = UIScrollView()
contentSectionScrollView = UIScrollView()
- arrowView = ArrowView(frame: CGRect(x: 0, y: 0, width: 30, height: 10))
+ arrowView = ArrowView(frame: CGRect(x: 0, y: 0, width: arrowWidth, height: arrowHeight))
self.addSubview(tabSectionScrollView)
self.addSubview(contentSectionScrollView)
@@ -120,7 +139,12 @@ open class ACTabScrollView: UIView, UIScrollViewDelegate {
// set custom attrs
tabSectionScrollView.backgroundColor = self.tabSectionBackgroundColor
contentSectionScrollView.backgroundColor = self.contentSectionBackgroundColor
- arrowView.arrorBackgroundColor = self.tabSectionBackgroundColor
+ arrowView.arrorBackgroundColor = self.arrowBackgroundColor
+<<<<<<< HEAD
+ arrowView.isUpsideArrowIndicator = self.isUpsideArrowIndicator
+=======
+ arrowView.upsideArrowDirection = self.upsideArrowDirection
+>>>>>>> 4bcac438ac34da53f3e7bd74ab50f7d6bca4f663
arrowView.isHidden = !arrowIndicator
// first time setup pages
@@ -173,7 +197,17 @@ open class ACTabScrollView: UIView, UIScrollViewDelegate {
seperatorView.backgroundColor = textColor
// arrow
- arrowView.frame.origin = CGPoint(x: (self.frame.width - arrowView.frame.width) / 2, y: tabSectionHeight)
+<<<<<<< HEAD
+ if isUpsideArrowIndicator {
+ arrowView.frame.origin = CGPoint(x: (self.bounds.width - arrowView.bounds.width) / 2, y: tabSectionHeight - arrowView.bounds.height)
+ } else {
+=======
+ if upsideArrowDirection{
+ arrowView.frame.origin = CGPoint(x: (self.bounds.width - arrowView.bounds.width) / 2, y: tabSectionHeight - arrowView.bounds.height)
+ }else{
+>>>>>>> 4bcac438ac34da53f3e7bd74ab50f7d6bca4f663
+ arrowView.frame.origin = CGPoint(x: (self.frame.width - arrowView.frame.width) / 2, y: tabSectionHeight)
+ }
// add subviews
self.addSubview(tabSectionLabel)
@@ -385,7 +419,21 @@ open class ACTabScrollView: UIView, UIScrollViewDelegate {
contentSectionScrollView.frame = CGRect(x: 0, y: tabSectionHeight, width: self.frame.size.width, height: contentSectionHeight)
// reset the origin of arrow view
- arrowView.frame.origin = CGPoint(x: (self.frame.width - arrowView.frame.width) / 2, y: tabSectionHeight)
+<<<<<<< HEAD
+ if isUpsideArrowIndicator {
+ arrowView.frame.origin = CGPoint(x: (self.bounds.width - arrowView.bounds.width) / 2, y: tabSectionHeight - arrowView.bounds.height)
+ } else {
+ arrowView.frame.origin = CGPoint(x: (self.frame.width - arrowView.frame.width) / 2, y: tabSectionHeight)
+ }
+=======
+
+ if upsideArrowDirection{
+ arrowView.frame.origin = CGPoint(x: (self.bounds.width - arrowView.bounds.width) / 2, y: tabSectionHeight - arrowView.bounds.height)
+ }else{
+ arrowView.frame.origin = CGPoint(x: (self.frame.width - arrowView.frame.width) / 2, y: tabSectionHeight)
+ }
+
+>>>>>>> 4bcac438ac34da53f3e7bd74ab50f7d6bca4f663
}
}
@@ -548,28 +596,71 @@ class ArrowView : UIView {
var rect: CGRect!
var arrorBackgroundColor: UIColor?
+<<<<<<< HEAD
+ var isUpsideArrowIndicator : Bool?
+=======
+ var upsideArrowDirection : Bool?
+>>>>>>> 4bcac438ac34da53f3e7bd74ab50f7d6bca4f663
var midX: CGFloat { return rect.midX }
var midY: CGFloat { return rect.midY }
var maxX: CGFloat { return rect.maxX }
var maxY: CGFloat { return rect.maxY }
+ // Change the arrow direction to up
override func draw(_ rect: CGRect) {
self.rect = rect
- let ctx = UIGraphicsGetCurrentContext()
+ guard let ctx = UIGraphicsGetCurrentContext() else { return }
+<<<<<<< HEAD
+
+ ctx.beginPath()
- ctx?.beginPath()
- ctx?.move(to: CGPoint(x: 0, y: 0))
- ctx?.addQuadCurve(to: CGPoint(x:maxX * 0.2 , y: maxY * 0.2), control: CGPoint(x: maxX * 0.12, y: 0))
- ctx?.addLine(to: CGPoint(x: midX - maxX * 0.05, y: maxY * 0.9))
- ctx?.addQuadCurve(to: CGPoint(x: midX + maxX * 0.05, y: maxY * 0.9), control: CGPoint(x: midX, y: maxY))
- ctx?.addLine(to: CGPoint(x: maxX * 0.8, y: maxY * 0.2))
- ctx?.addQuadCurve(to: CGPoint(x: maxX, y: 0), control: CGPoint(x: maxX * 0.88, y: 0))
- ctx?.closePath()
+ if isUpsideArrowIndicator! {
+ ctx.move(to: CGPoint(x: 0, y: 1))
+ ctx.addQuadCurve(to: CGPoint(x: maxX * 0.2 , y: maxY * 0.8), control: CGPoint(x: maxX * 0.12, y: 1))
+ ctx.addLine(to: CGPoint(x: midX - maxX * 0.05, y: maxY * 0.1))
+ ctx.addQuadCurve(to: CGPoint(x: midX + maxX * 0.05, y: maxY * 0.1), control: CGPoint(x: midX, y: maxY))
+ ctx.addLine(to: CGPoint(x: maxX * 0.8, y: maxY * 0.8))
+ ctx.addQuadCurve(to: CGPoint(x: maxX, y: 1), control: CGPoint(x: maxX * 0.88, y: 0))
+ } else {
+ ctx.move(to: CGPoint(x: 0, y: 0))
+ ctx.addQuadCurve(to: CGPoint(x: maxX * 0.2 , y: maxY * 0.2), control: CGPoint(x: maxX * 0.12, y: 0))
+ ctx.addLine(to: CGPoint(x: midX - maxX * 0.05, y: maxY * 0.9))
+ ctx.addQuadCurve(to: CGPoint(x: midX + maxX * 0.05, y: maxY * 0.9), control: CGPoint(x: midX, y: maxY))
+ ctx.addLine(to: CGPoint(x: maxX * 0.8, y: maxY * 0.2))
+ ctx.addQuadCurve(to: CGPoint(x: maxX, y: 0), control: CGPoint(x: maxX * 0.88, y: 0))
+ }
- ctx?.setFillColor((arrorBackgroundColor?.cgColor)!)
- ctx?.fillPath();
+ ctx.closePath()
+ ctx.setFillColor((arrorBackgroundColor?.cgColor)!)
+ ctx.fillPath();
+=======
+
+ if upsideArrowDirection!{
+ ctx.beginPath()
+ ctx.move(to: CGPoint(x: 0, y: bounds.maxY))
+ ctx.addLine(to: CGPoint(x: bounds.midX, y: bounds.minY))
+ ctx.addLine(to: CGPoint(x: bounds.maxX, y: bounds.maxY))
+ ctx.addLine(to: CGPoint(x: 0, y: bounds.maxY))
+ ctx.closePath()
+
+ ctx.setFillColor((arrorBackgroundColor?.cgColor)!)
+ ctx.fillPath()
+ }else{
+ ctx.beginPath()
+ ctx.move(to: CGPoint(x: 0, y: 0))
+ ctx.addQuadCurve(to: CGPoint(x:maxX * 0.2 , y: maxY * 0.2), control: CGPoint(x: maxX * 0.12, y: 0))
+ ctx.addLine(to: CGPoint(x: midX - maxX * 0.05, y: maxY * 0.9))
+ ctx.addQuadCurve(to: CGPoint(x: midX + maxX * 0.05, y: maxY * 0.9), control: CGPoint(x: midX, y: maxY))
+ ctx.addLine(to: CGPoint(x: maxX * 0.8, y: maxY * 0.2))
+ ctx.addQuadCurve(to: CGPoint(x: maxX, y: 0), control: CGPoint(x: maxX * 0.88, y: 0))
+ ctx.closePath()
+
+ ctx.setFillColor((arrorBackgroundColor?.cgColor)!)
+ ctx.fillPath();
+ }
+>>>>>>> 4bcac438ac34da53f3e7bd74ab50f7d6bca4f663
}
}