Skip to content

Commit

Permalink
fix some thing
Browse files Browse the repository at this point in the history
  • Loading branch information
DuckDeck committed Dec 20, 2016
1 parent f1d1aa6 commit 383ba28
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 19 deletions.
1 change: 1 addition & 0 deletions .swift-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0
4 changes: 2 additions & 2 deletions GrandMenu.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |s|
#

s.name = "GrandMenu"
s.version = "1.0.0"
s.version = "1.0.1"
s.summary = "GrandMenu is a powerful and simple Menu"

# This description is used to generate tags and improve search results.
Expand Down Expand Up @@ -80,7 +80,7 @@ Pod::Spec.new do |s|
# Supports git, hg, bzr, svn and HTTP.
#

s.source = { :git => "https://github.com/DuckDeck/GrandMenu.git", :tag => "1.0.0" }
s.source = { :git => "https://github.com/DuckDeck/GrandMenu.git", :tag => "1.0.1" }


# ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
Expand Down
2 changes: 1 addition & 1 deletion GrandMenu/GrandMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ open class GrandMenu: UIView,GraneMenuItemDelegate {
item.delegate = weakSelf
var itemWidth = GrandMenuItem.getTitleWidth(title,fontSize: item.fontSize)
if averageManu{
itemWidth = Float(UIScreen.main.bounds.width / CGFloat(arrItemsTitle!.count))
itemWidth = Float(frame.size.width / CGFloat(arrItemsTitle!.count))
}
item.frame = CGRect(x: CGFloat(x), y: CGFloat(0), width: CGFloat(itemWidth), height: scrollView!.frame.height)
item.title = title
Expand Down
57 changes: 42 additions & 15 deletions GrandMenu/GrandMenuTable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,26 @@
import UIKit

open class GrandMenuTable: UIView,UITableViewDataSource,UITableViewDelegate {
open var tb:UITableView?
fileprivate var arrViewControllers:[UIViewController]?
fileprivate var arrViews:[UIView]?
open var scrollToIndex:((_ index:Int)->Void)?
open var tb:UITableView?
fileprivate var arrViewControllers:[UIViewController]?
fileprivate var arrViews:[UIView]?
open var cellBgColor = UIColor.clear
public var itemCount:Int{
get{
if arrViewControllers != nil{
return arrViewControllers!.count
}
else if arrViews != nil{
return arrViews!.count
}
return 0
}
}
open var scrollToIndex:((_ index:Int)->Void)?
fileprivate override init(frame: CGRect) {
super.init(frame: frame)
}
public convenience init(frame:CGRect,arrViewControllers:[UIViewController]){
public convenience init(frame:CGRect,arrViewControllers:[UIViewController]){
self.init(frame:frame)
self.arrViewControllers = arrViewControllers
tb = UITableView()
Expand Down Expand Up @@ -48,7 +60,11 @@ open class GrandMenuTable: UIView,UITableViewDataSource,UITableViewDelegate {
addSubview(tb!)
}


public func addController(controller:UIViewController){
arrViewControllers?.append(controller)
let index = IndexPath(row: arrViewControllers!.count - 1, section: 0)
tb?.reloadRows(at: [index], with: .none)
}

required public init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
Expand All @@ -71,14 +87,25 @@ open class GrandMenuTable: UIView,UITableViewDataSource,UITableViewDelegate {
cell = UITableViewCell(style: UITableViewCellStyle.default, reuseIdentifier: "GrandCell")
cell?.transform = CGAffineTransform(rotationAngle: CGFloat(M_PI_2))
cell?.selectionStyle = .none
cell?.backgroundColor = cellBgColor
cell?.contentView.backgroundColor = UIColor.clear
}
if arrViewControllers != nil{
if arrViewControllers != nil {
if cell!.contentView.subviews.count > 0{
for v in cell!.contentView.subviews{
v.removeFromSuperview()
}
}
let v = arrViewControllers![(indexPath as NSIndexPath).row]
v.view.frame = cell!.bounds
cell?.contentView.addSubview(v.view)
}
else if arrViews != nil{
else if arrViews != nil {
if cell!.contentView.subviews.count > 0{
for v in cell!.contentView.subviews{
v.removeFromSuperview()
}
}
let v = arrViews![(indexPath as NSIndexPath).row]
cell?.contentView.addSubview(v)
}
Expand All @@ -96,11 +123,11 @@ open class GrandMenuTable: UIView,UITableViewDataSource,UITableViewDelegate {
}
}

open func selectIndex(_ index:Int){
weak var weakSelf = self
UIView.animate(withDuration: 0.3, animations: { () -> Void in
weakSelf?.tb?.scrollToRow(at: IndexPath(row: index, section: 0), at: .none, animated: true)
})
}

open func selectIndex(_ index:Int){
weak var weakSelf = self
UIView.animate(withDuration: 0.3, animations: { () -> Void in
weakSelf?.tb?.scrollToRow(at: IndexPath(row: index, section: 0), at: .none, animated: true)
})
}
}
Binary file modified GrandMenuDemo/.DS_Store
Binary file not shown.
10 changes: 9 additions & 1 deletion GrandMenuDemo/GrandMenuDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,13 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0720;
LastUpgradeCheck = 0820;
ORGANIZATIONNAME = Qfq;
TargetAttributes = {
A205AA6C1C488E880043F5F6 = {
CreatedOnToolsVersion = 7.2;
LastSwiftMigration = 0800;
ProvisioningStyle = Manual;
};
};
};
Expand Down Expand Up @@ -241,8 +242,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand Down Expand Up @@ -285,8 +288,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand All @@ -305,6 +310,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 9.2;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
VALIDATE_PRODUCT = YES;
};
name = Release;
Expand All @@ -313,6 +319,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = GrandMenuDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
Expand All @@ -326,6 +333,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = GrandMenuDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
Expand Down

0 comments on commit 383ba28

Please sign in to comment.