diff --git a/.swift-version b/.swift-version new file mode 100644 index 0000000..9f55b2c --- /dev/null +++ b/.swift-version @@ -0,0 +1 @@ +3.0 diff --git a/GrandMenu.podspec b/GrandMenu.podspec index d87b084..b5c752d 100644 --- a/GrandMenu.podspec +++ b/GrandMenu.podspec @@ -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. @@ -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 ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # diff --git a/GrandMenu/GrandMenu.swift b/GrandMenu/GrandMenu.swift index 734a7e5..541586d 100644 --- a/GrandMenu/GrandMenu.swift +++ b/GrandMenu/GrandMenu.swift @@ -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 diff --git a/GrandMenu/GrandMenuTable.swift b/GrandMenu/GrandMenuTable.swift index 986ab4c..3ac6bae 100644 --- a/GrandMenu/GrandMenuTable.swift +++ b/GrandMenu/GrandMenuTable.swift @@ -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() @@ -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") @@ -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) } @@ -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) + }) + } + } diff --git a/GrandMenuDemo/.DS_Store b/GrandMenuDemo/.DS_Store index bdc5dab..9404501 100644 Binary files a/GrandMenuDemo/.DS_Store and b/GrandMenuDemo/.DS_Store differ diff --git a/GrandMenuDemo/GrandMenuDemo.xcodeproj/project.pbxproj b/GrandMenuDemo/GrandMenuDemo.xcodeproj/project.pbxproj index 7b7c7d4..8ed8da2 100644 --- a/GrandMenuDemo/GrandMenuDemo.xcodeproj/project.pbxproj +++ b/GrandMenuDemo/GrandMenuDemo.xcodeproj/project.pbxproj @@ -152,12 +152,13 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0720; - LastUpgradeCheck = 0720; + LastUpgradeCheck = 0820; ORGANIZATIONNAME = Qfq; TargetAttributes = { A205AA6C1C488E880043F5F6 = { CreatedOnToolsVersion = 7.2; LastSwiftMigration = 0800; + ProvisioningStyle = Manual; }; }; }; @@ -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"; @@ -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"; @@ -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; @@ -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"; @@ -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";