From 771d9bd96f0219c1841ab27e541eff94c3b0e317 Mon Sep 17 00:00:00 2001 From: corin8823 Date: Wed, 19 Aug 2015 22:56:00 +0900 Subject: [PATCH] Create Project --- .gitignore | 16 +- {Pod/Assets => Classes}/.gitkeep | 0 Classes/Popover.swift | 296 ++++++++++++++++++ Example/Podfile | 13 +- Example/Podfile.lock | 14 + Example/Popover.xcodeproj/project.pbxproj | 226 ++----------- .../xcschemes/Popover-Example.xcscheme | 112 ------- .../contents.xcworkspacedata | 10 + Example/Popover/AppDelegate.swift | 52 ++- Example/Popover/Base.lproj/Main.storyboard | 91 +++++- Example/Popover/Info.plist | 1 - Example/Popover/ViewController.swift | 70 ++++- Example/Tests/Tests.swift | 44 +-- Pod/Classes/.gitkeep | 0 Pod/Classes/ReplaceMe.swift | 0 Popover.podspec | 40 +-- README.md | 39 ++- _Pods.xcodeproj | 1 - 18 files changed, 598 insertions(+), 427 deletions(-) rename {Pod/Assets => Classes}/.gitkeep (100%) create mode 100644 Classes/Popover.swift create mode 100644 Example/Podfile.lock delete mode 100644 Example/Popover.xcodeproj/xcshareddata/xcschemes/Popover-Example.xcscheme create mode 100644 Example/Popover.xcworkspace/contents.xcworkspacedata delete mode 100644 Pod/Classes/.gitkeep delete mode 100644 Pod/Classes/ReplaceMe.swift delete mode 120000 _Pods.xcodeproj diff --git a/.gitignore b/.gitignore index f067d67..5debd2d 100644 --- a/.gitignore +++ b/.gitignore @@ -18,16 +18,14 @@ profile DerivedData *.hmap *.ipa +*.xcuserstate # Bundler .bundle -Carthage -# We recommend against adding the Pods directory to your .gitignore. However -# you should judge for yourself, the pros and cons are mentioned at: -# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control -# -# Note: if you ignore the Pods directory, make sure to uncomment -# `pod install` in .travis.yml -# -# Pods/ +# Carthage +Carthage/Build/* +Carthage/Checkouts/* + +# CocoaPods +Pods/ \ No newline at end of file diff --git a/Pod/Assets/.gitkeep b/Classes/.gitkeep similarity index 100% rename from Pod/Assets/.gitkeep rename to Classes/.gitkeep diff --git a/Classes/Popover.swift b/Classes/Popover.swift new file mode 100644 index 0000000..48db866 --- /dev/null +++ b/Classes/Popover.swift @@ -0,0 +1,296 @@ +// +// Popover.swift +// Popover +// +// Created by corin8823 on 8/16/15. +// Copyright (c) 2015 corin8823. All rights reserved. +// + +import UIKit + +public enum PopoverOption { + case ArrowSize(CGSize) + case AnimationIn(NSTimeInterval) + case AnimationOut(NSTimeInterval) + case CornerRadius(CGFloat) + case SideEdge(CGFloat) + case BlackOverlayColor(UIColor) + case Type(Popover.PopoverType) +} + +public class Popover: UIView { + + public enum PopoverType { + case Up + case Down + } + + // custom property + private var arrowSize: CGSize = CGSize(width: 16.0, height: 10.0) + private var animationIn: NSTimeInterval = 0.6 + private var animationOut: NSTimeInterval = 0.3 + private var cornerRadius: CGFloat = 6.0 + private var sideEdge: CGFloat = 20.0 + private var popoverType: PopoverType = .Down + private var blackOverlayColor: UIColor = UIColor(white: 0.0, alpha: 0.2) + + // custom closure + private var didShowHandler: (() -> ())? + private var didDismissHandler: (() -> ())? + + private var blackOverlay: UIControl = UIControl() + private var containerView: UIView! + private var contentView: UIView! + private var contentViewFrame: CGRect! + private var arrowShowPoint: CGPoint! + + public init() { + super.init(frame: CGRectZero) + self.backgroundColor = UIColor.clearColor() + } + + public init(options: [PopoverOption]?) { + super.init(frame: CGRectZero) + self.backgroundColor = UIColor.clearColor() + self.setOptions(options) + } + + public init(showHandler: (() -> ())?, dismissHandler: (() -> ())?) { + super.init(frame: CGRectZero) + self.backgroundColor = UIColor.clearColor() + self.didShowHandler = showHandler + self.didDismissHandler = dismissHandler + } + + public init(options: [PopoverOption]?, showHandler: (() -> ())?, dismissHandler: (() -> ())?) { + super.init(frame: CGRectZero) + self.backgroundColor = UIColor.clearColor() + self.setOptions(options) + self.didShowHandler = showHandler + self.didDismissHandler = dismissHandler + } + + private func setOptions(options: [PopoverOption]?){ + if let options = options { + for option in options { + switch option { + case let .ArrowSize(value): + self.arrowSize = value + case let .AnimationIn(value): + self.animationIn = value + case let .AnimationOut(value): + self.animationOut = value + case let .CornerRadius(value): + self.cornerRadius = value + case let .SideEdge(value): + self.sideEdge = value + case let .BlackOverlayColor(value): + self.blackOverlayColor = value + case let .Type(value): + self.popoverType = value + } + } + } + } + + required public init(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + override public func layoutSubviews() { + super.layoutSubviews() + self.create() + } + + private func create() { + var frame = self.contentView.frame + frame.origin.x = self.arrowShowPoint.x - frame.size.width * 0.5 + + var sideEdge: CGFloat = 0.0 + if frame.size.width < self.containerView.frame.size.width { + sideEdge = self.sideEdge + } + + var outerSideEdge = CGRectGetMaxX(frame) - self.containerView.bounds.size.width + if outerSideEdge > 0 { + frame.origin.x -= (outerSideEdge + sideEdge) + } else { + if CGRectGetMinX(frame) < 0 { + frame.origin.x += abs(CGRectGetMinX(frame)) + sideEdge + } + } + self.frame = frame + + var arrowPoint = self.containerView.convertPoint(self.arrowShowPoint, toView: self) + let anchorPoint: CGPoint + switch self.popoverType { + case .Up: + frame.origin.y = self.arrowShowPoint.y - frame.height - self.arrowSize.height + anchorPoint = CGPoint(x: arrowPoint.x / frame.size.width, y: 1) + case .Down: + frame.origin.y = self.arrowShowPoint.y + anchorPoint = CGPoint(x: arrowPoint.x / frame.size.width, y: 0) + } + + var lastAnchor = self.layer.anchorPoint + self.layer.anchorPoint = anchorPoint + var x = self.layer.position.x + (anchorPoint.x - lastAnchor.x) * self.layer.bounds.size.width + var y = self.layer.position.y + (anchorPoint.y - lastAnchor.y) * self.layer.bounds.size.height + self.layer.position = CGPoint(x: x, y: y) + + frame.size.height += self.arrowSize.height + self.frame = frame + } + + public func show(contentView: UIView, fromView: UIView) { + let point: CGPoint + switch self.popoverType { + case .Up: + point = CGPoint(x: fromView.frame.origin.x + (fromView.frame.size.width / 2), y: fromView.frame.origin.y) + case .Down: + point = CGPoint(x: fromView.frame.origin.x + (fromView.frame.size.width / 2), y: fromView.frame.origin.y + fromView.frame.size.height) + } + self.show(contentView, point: point) + } + + public func show(contentView: UIView, point: CGPoint) { + let inView = UIApplication.sharedApplication().keyWindow! + self.blackOverlay.autoresizingMask = .FlexibleWidth | .FlexibleHeight + self.blackOverlay.frame = inView.bounds + self.blackOverlay.backgroundColor = self.blackOverlayColor + inView.addSubview(self.blackOverlay) + + self.blackOverlay.addTarget(self, action: "dismiss", forControlEvents: .TouchUpInside) + + self.containerView = inView + self.contentView = contentView + self.contentView.backgroundColor = UIColor.clearColor() + self.contentView.layer.cornerRadius = self.cornerRadius + self.contentView.layer.masksToBounds = true + self.arrowShowPoint = point + self.show() + } + + private func show() { + self.setNeedsDisplay() + switch self.popoverType { + case .Up: + self.contentView.frame.origin.y = 0.0 + case .Down: + self.contentView.frame.origin.y = self.arrowSize.height + } + self.addSubview(self.contentView) + self.containerView.addSubview(self) + + self.transform = CGAffineTransformMakeScale(0.0, 0.0) + UIView.animateWithDuration(self.animationIn, delay: 0, + usingSpringWithDamping: 0.7, + initialSpringVelocity: 3, + options: .CurveEaseInOut, + animations: { + self.transform = CGAffineTransformIdentity + }){ _ in + self.didShowHandler?() + } + } + + public func dismiss() { + if self.superview != nil { + UIView.animateWithDuration(self.animationOut, delay: 0, + options: .CurveEaseInOut, + animations: { + self.transform = CGAffineTransformMakeScale(0.0001, 0.0001) + }){ _ in + self.contentView.removeFromSuperview() + self.blackOverlay.removeFromSuperview() + self.removeFromSuperview() + self.didDismissHandler?() + } + } + } + + override public func drawRect(rect: CGRect) { + super.drawRect(rect) + var arrow = UIBezierPath() + var color = UIColor.whiteColor() + var arrowPoint = self.containerView.convertPoint(self.arrowShowPoint, toView: self) + switch self.popoverType { + case .Up: + arrow.moveToPoint(CGPoint(x: arrowPoint.x, y: self.bounds.height)) + arrow.addLineToPoint(CGPoint(x: arrowPoint.x - self.arrowSize.width * 0.5, y: self.bounds.height - self.arrowSize.height)) + + arrow.addLineToPoint(CGPoint(x: self.cornerRadius, y: self.bounds.height - self.arrowSize.height)) + arrow.addArcWithCenter(CGPoint(x: self.cornerRadius, y: self.bounds.height - self.arrowSize.height - self.cornerRadius), + radius: self.cornerRadius, + startAngle: self.radians(90), + endAngle: self.radians(180), + clockwise: true) + + arrow.addLineToPoint(CGPoint(x: 0, y: self.cornerRadius)) + arrow.addArcWithCenter(CGPoint(x: self.cornerRadius, y: self.cornerRadius), + radius: self.cornerRadius, + startAngle: self.radians(180), + endAngle: self.radians(270), + clockwise: true) + + arrow.addLineToPoint(CGPoint(x: self.bounds.width - self.cornerRadius, y: 0)) + arrow.addArcWithCenter(CGPoint(x: self.bounds.width - self.cornerRadius, y: self.cornerRadius), + radius: self.cornerRadius, + startAngle: self.radians(270), + endAngle: self.radians(0), + clockwise: true) + + arrow.addLineToPoint(CGPoint(x: self.bounds.width, y: self.bounds.height - self.arrowSize.height - self.cornerRadius)) + arrow.addArcWithCenter(CGPoint(x: self.bounds.width - self.cornerRadius, y: self.bounds.height - self.arrowSize.height - self.cornerRadius), + radius: self.cornerRadius, + startAngle: self.radians(0), + endAngle: self.radians(90), + clockwise: true) + + arrow.addLineToPoint(CGPoint(x: arrowPoint.x + self.arrowSize.width * 0.5, + y: self.bounds.height - self.arrowSize.height)) + + case .Down: + arrow.moveToPoint(CGPoint(x: arrowPoint.x, y: 0)) + arrow.addLineToPoint(CGPoint(x: arrowPoint.x + self.arrowSize.width * 0.5, y: self.arrowSize.height)) + + arrow.addLineToPoint(CGPoint(x: self.bounds.width - self.cornerRadius, y: self.arrowSize.height)) + arrow.addArcWithCenter(CGPoint(x: self.bounds.width - self.cornerRadius, y: self.arrowSize.height + self.cornerRadius), + radius: self.cornerRadius, + startAngle: self.radians(270.0), + endAngle: self.radians(0), + clockwise: true) + + arrow.addLineToPoint(CGPoint(x: self.bounds.width, y: self.bounds.height - self.cornerRadius)) + arrow.addArcWithCenter(CGPoint(x: self.bounds.width - self.cornerRadius, y: self.bounds.height - self.cornerRadius), + radius: self.cornerRadius, + startAngle: self.radians(0), + endAngle: self.radians(90), + clockwise: true) + + arrow.addLineToPoint(CGPoint(x: 0, y: self.bounds.height)) + arrow.addArcWithCenter(CGPoint(x: self.cornerRadius, y: self.bounds.height - self.cornerRadius), + radius: self.cornerRadius, + startAngle: self.radians(90), + endAngle: self.radians(180), + clockwise: true) + + arrow.addLineToPoint(CGPoint(x: 0, y: self.arrowSize.height + self.cornerRadius)) + arrow.addArcWithCenter(CGPoint(x: self.cornerRadius, y: self.arrowSize.height + self.cornerRadius), + radius: self.cornerRadius, + startAngle: self.radians(180), + endAngle: self.radians(270), + clockwise: true) + + arrow.addLineToPoint(CGPoint(x: arrowPoint.x - self.arrowSize.width * 0.5, + y: self.arrowSize.height)) + } + + color.setFill() + arrow.fill() + } + + private func radians(degrees: CGFloat) -> CGFloat { + return (CGFloat(M_PI) * degrees / 180) + } +} \ No newline at end of file diff --git a/Example/Podfile b/Example/Podfile index a67f2fa..3a76275 100644 --- a/Example/Podfile +++ b/Example/Podfile @@ -1,12 +1,7 @@ source 'https://github.com/CocoaPods/Specs.git' +platform :ios, '8.0' use_frameworks! -target 'Popover_Example', :exclusive => true do - pod "Popover", :path => "../" -end - -target 'Popover_Tests', :exclusive => true do - pod "Popover", :path => "../" - - pod 'FBSnapshotTestCase' -end +target 'PopoverExample' do + pod 'Popover', :path => '..' +end \ No newline at end of file diff --git a/Example/Podfile.lock b/Example/Podfile.lock new file mode 100644 index 0000000..67ecf51 --- /dev/null +++ b/Example/Podfile.lock @@ -0,0 +1,14 @@ +PODS: + - Popover (0.1.0) + +DEPENDENCIES: + - Popover (from `..`) + +EXTERNAL SOURCES: + Popover: + :path: .. + +SPEC CHECKSUMS: + Popover: 418c76f60ba6037a7a3b0b940d7247c0439388a0 + +COCOAPODS: 0.38.2 diff --git a/Example/Popover.xcodeproj/project.pbxproj b/Example/Popover.xcodeproj/project.pbxproj index f05a648..d7d772d 100644 --- a/Example/Popover.xcodeproj/project.pbxproj +++ b/Example/Popover.xcodeproj/project.pbxproj @@ -7,46 +7,30 @@ objects = { /* Begin PBXBuildFile section */ - 604690100BD3F0E377C1AD60 /* Pods_Popover_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F3B19DAC946FB6E7D89E7D2F /* Pods_Popover_Tests.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; 607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD51AFB9204008FA782 /* AppDelegate.swift */; }; 607FACD81AFB9204008FA782 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD71AFB9204008FA782 /* ViewController.swift */; }; 607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 607FACD91AFB9204008FA782 /* Main.storyboard */; }; 607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDC1AFB9204008FA782 /* Images.xcassets */; }; 607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */; }; - 607FACEC1AFB9204008FA782 /* Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACEB1AFB9204008FA782 /* Tests.swift */; }; - DAFF3D0B2B48B99F501A9E6F /* Pods_Popover_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B64FA496F0FA5CA1F9617F67 /* Pods_Popover_Example.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; + FC878B3EE3D456A4FE51F050 /* Pods_PopoverExample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 945A9DE60C512AAD75BE4342 /* Pods_PopoverExample.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; /* End PBXBuildFile section */ -/* Begin PBXContainerItemProxy section */ - 607FACE61AFB9204008FA782 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 607FACC81AFB9204008FA782 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 607FACCF1AFB9204008FA782; - remoteInfo = Popover; - }; -/* End PBXContainerItemProxy section */ - /* Begin PBXFileReference section */ 0C7CA225928466CCAA26D51E /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = ""; }; - 3E81893BA7937BFB9ADA112F /* Pods-Popover_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Popover_Tests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Popover_Tests/Pods-Popover_Tests.debug.xcconfig"; sourceTree = ""; }; - 4B36D54FF22B6FDA9B17094A /* Pods-Popover_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Popover_Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-Popover_Tests/Pods-Popover_Tests.release.xcconfig"; sourceTree = ""; }; - 607FACD01AFB9204008FA782 /* Popover_Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Popover_Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 5F719E92C96EEFA1D3B903A2 /* Pods-PopoverExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PopoverExample.debug.xcconfig"; path = "Pods/Target Support Files/Pods-PopoverExample/Pods-PopoverExample.debug.xcconfig"; sourceTree = ""; }; + 607FACD01AFB9204008FA782 /* PopoverExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PopoverExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 607FACD41AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 607FACD51AFB9204008FA782 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 607FACD71AFB9204008FA782 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 607FACDA1AFB9204008FA782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 607FACDC1AFB9204008FA782 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 607FACDF1AFB9204008FA782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; - 607FACE51AFB9204008FA782 /* Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; name = Tests.xctest; path = Popover_Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 607FACEA1AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 607FACEB1AFB9204008FA782 /* Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tests.swift; sourceTree = ""; }; 65A80BF69ABA0864389E626F /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = ""; }; 932FBC229015BD6FEF162C71 /* Popover.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = Popover.podspec; path = ../Popover.podspec; sourceTree = ""; }; - A852A802E039AA645C475B21 /* Pods-Popover_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Popover_Example.release.xcconfig"; path = "Pods/Target Support Files/Pods-Popover_Example/Pods-Popover_Example.release.xcconfig"; sourceTree = ""; }; - B64FA496F0FA5CA1F9617F67 /* Pods_Popover_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Popover_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - D231E1FE361A83E1AFD13AEF /* Pods-Popover_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Popover_Example.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Popover_Example/Pods-Popover_Example.debug.xcconfig"; sourceTree = ""; }; - F3B19DAC946FB6E7D89E7D2F /* Pods_Popover_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Popover_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 945A9DE60C512AAD75BE4342 /* Pods_PopoverExample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_PopoverExample.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + E4FEC7E2CFAC48E5570D4855 /* Pods-PopoverExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PopoverExample.release.xcconfig"; path = "Pods/Target Support Files/Pods-PopoverExample/Pods-PopoverExample.release.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -54,15 +38,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - DAFF3D0B2B48B99F501A9E6F /* Pods_Popover_Example.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 607FACE21AFB9204008FA782 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 604690100BD3F0E377C1AD60 /* Pods_Popover_Tests.framework in Frameworks */, + FC878B3EE3D456A4FE51F050 /* Pods_PopoverExample.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -73,7 +49,7 @@ isa = PBXGroup; children = ( 607FACF51AFB993E008FA782 /* Podspec Metadata */, - 607FACD21AFB9204008FA782 /* Example for Popover */, + 607FACD21AFB9204008FA782 /* Popover */, 607FACE81AFB9204008FA782 /* Tests */, 607FACD11AFB9204008FA782 /* Products */, 839BBD2BA6391DE80A183710 /* Pods */, @@ -84,13 +60,12 @@ 607FACD11AFB9204008FA782 /* Products */ = { isa = PBXGroup; children = ( - 607FACD01AFB9204008FA782 /* Popover_Example.app */, - 607FACE51AFB9204008FA782 /* Tests.xctest */, + 607FACD01AFB9204008FA782 /* PopoverExample.app */, ); name = Products; sourceTree = ""; }; - 607FACD21AFB9204008FA782 /* Example for Popover */ = { + 607FACD21AFB9204008FA782 /* Popover */ = { isa = PBXGroup; children = ( 607FACD51AFB9204008FA782 /* AppDelegate.swift */, @@ -100,7 +75,6 @@ 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */, 607FACD31AFB9204008FA782 /* Supporting Files */, ); - name = "Example for Popover"; path = Popover; sourceTree = ""; }; @@ -142,10 +116,8 @@ 839BBD2BA6391DE80A183710 /* Pods */ = { isa = PBXGroup; children = ( - D231E1FE361A83E1AFD13AEF /* Pods-Popover_Example.debug.xcconfig */, - A852A802E039AA645C475B21 /* Pods-Popover_Example.release.xcconfig */, - 3E81893BA7937BFB9ADA112F /* Pods-Popover_Tests.debug.xcconfig */, - 4B36D54FF22B6FDA9B17094A /* Pods-Popover_Tests.release.xcconfig */, + 5F719E92C96EEFA1D3B903A2 /* Pods-PopoverExample.debug.xcconfig */, + E4FEC7E2CFAC48E5570D4855 /* Pods-PopoverExample.release.xcconfig */, ); name = Pods; sourceTree = ""; @@ -153,8 +125,7 @@ BF9C5ECA7CBED3A3A63F76B6 /* Frameworks */ = { isa = PBXGroup; children = ( - B64FA496F0FA5CA1F9617F67 /* Pods_Popover_Example.framework */, - F3B19DAC946FB6E7D89E7D2F /* Pods_Popover_Tests.framework */, + 945A9DE60C512AAD75BE4342 /* Pods_PopoverExample.framework */, ); name = Frameworks; sourceTree = ""; @@ -162,9 +133,9 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ - 607FACCF1AFB9204008FA782 /* Popover_Example */ = { + 607FACCF1AFB9204008FA782 /* PopoverExample */ = { isa = PBXNativeTarget; - buildConfigurationList = 607FACEF1AFB9204008FA782 /* Build configuration list for PBXNativeTarget "Popover_Example" */; + buildConfigurationList = 607FACEF1AFB9204008FA782 /* Build configuration list for PBXNativeTarget "PopoverExample" */; buildPhases = ( E1CCF52EED08F347EB38D8F1 /* Check Pods Manifest.lock */, 607FACCC1AFB9204008FA782 /* Sources */, @@ -177,32 +148,11 @@ ); dependencies = ( ); - name = Popover_Example; + name = PopoverExample; productName = Popover; - productReference = 607FACD01AFB9204008FA782 /* Popover_Example.app */; + productReference = 607FACD01AFB9204008FA782 /* PopoverExample.app */; productType = "com.apple.product-type.application"; }; - 607FACE41AFB9204008FA782 /* Popover_Tests */ = { - isa = PBXNativeTarget; - buildConfigurationList = 607FACF21AFB9204008FA782 /* Build configuration list for PBXNativeTarget "Popover_Tests" */; - buildPhases = ( - 5B55BAA26F15600825DEAFDB /* Check Pods Manifest.lock */, - 607FACE11AFB9204008FA782 /* Sources */, - 607FACE21AFB9204008FA782 /* Frameworks */, - 607FACE31AFB9204008FA782 /* Resources */, - 1B190525EC86B2898B734440 /* Embed Pods Frameworks */, - BD301E86DCAA95D9254390C5 /* Copy Pods Resources */, - ); - buildRules = ( - ); - dependencies = ( - 607FACE71AFB9204008FA782 /* PBXTargetDependency */, - ); - name = Popover_Tests; - productName = Tests; - productReference = 607FACE51AFB9204008FA782 /* Tests.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; - }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -215,10 +165,6 @@ 607FACCF1AFB9204008FA782 = { CreatedOnToolsVersion = 6.3.1; }; - 607FACE41AFB9204008FA782 = { - CreatedOnToolsVersion = 6.3.1; - TestTargetID = 607FACCF1AFB9204008FA782; - }; }; }; buildConfigurationList = 607FACCB1AFB9204008FA782 /* Build configuration list for PBXProject "Popover" */; @@ -234,8 +180,7 @@ projectDirPath = ""; projectRoot = ""; targets = ( - 607FACCF1AFB9204008FA782 /* Popover_Example */, - 607FACE41AFB9204008FA782 /* Popover_Tests */, + 607FACCF1AFB9204008FA782 /* PopoverExample */, ); }; /* End PBXProject section */ @@ -251,46 +196,9 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 607FACE31AFB9204008FA782 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 1B190525EC86B2898B734440 /* Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "Embed Pods Frameworks"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Popover_Tests/Pods-Popover_Tests-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; - 5B55BAA26F15600825DEAFDB /* Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "Check Pods Manifest.lock"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; - showEnvVarsInLog = 0; - }; BA478672D1B203E05C5DE1C0 /* Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -303,22 +211,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Popover_Example/Pods-Popover_Example-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; - BD301E86DCAA95D9254390C5 /* Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "Copy Pods Resources"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Popover_Tests/Pods-Popover_Tests-resources.sh\"\n"; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-PopoverExample/Pods-PopoverExample-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; DE763D1E30AE476F4A2ADBED /* Copy Pods Resources */ = { @@ -333,7 +226,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Popover_Example/Pods-Popover_Example-resources.sh\"\n"; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-PopoverExample/Pods-PopoverExample-resources.sh\"\n"; showEnvVarsInLog = 0; }; E1CCF52EED08F347EB38D8F1 /* Check Pods Manifest.lock */ = { @@ -363,24 +256,8 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 607FACE11AFB9204008FA782 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 607FACEC1AFB9204008FA782 /* Tests.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXSourcesBuildPhase section */ -/* Begin PBXTargetDependency section */ - 607FACE71AFB9204008FA782 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 607FACCF1AFB9204008FA782 /* Popover_Example */; - targetProxy = 607FACE61AFB9204008FA782 /* PBXContainerItemProxy */; - }; -/* End PBXTargetDependency section */ - /* Begin PBXVariantGroup section */ 607FACD91AFB9204008FA782 /* Main.storyboard */ = { isa = PBXVariantGroup; @@ -437,7 +314,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.3; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -475,7 +352,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.3; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; VALIDATE_PRODUCT = YES; @@ -484,10 +361,15 @@ }; 607FACF01AFB9204008FA782 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = D231E1FE361A83E1AFD13AEF /* Pods-Popover_Example.debug.xcconfig */; + baseConfigurationReference = 5F719E92C96EEFA1D3B903A2 /* Pods-PopoverExample.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/build/Debug-iphoneos", + ); INFOPLIST_FILE = Popover/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; MODULE_NAME = ExampleApp; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -496,49 +378,18 @@ }; 607FACF11AFB9204008FA782 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = A852A802E039AA645C475B21 /* Pods-Popover_Example.release.xcconfig */; + baseConfigurationReference = E4FEC7E2CFAC48E5570D4855 /* Pods-PopoverExample.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - INFOPLIST_FILE = Popover/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - MODULE_NAME = ExampleApp; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Release; - }; - 607FACF31AFB9204008FA782 /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 3E81893BA7937BFB9ADA112F /* Pods-Popover_Tests.debug.xcconfig */; - buildSettings = { - BUNDLE_LOADER = "$(TEST_HOST)"; - FRAMEWORK_SEARCH_PATHS = ( - "$(SDKROOT)/Developer/Library/Frameworks", - "$(inherited)", - ); - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - INFOPLIST_FILE = Tests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_NAME = "$(TARGET_NAME)"; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Popover_Example.app/Popover_Example"; - }; - name = Debug; - }; - 607FACF41AFB9204008FA782 /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 4B36D54FF22B6FDA9B17094A /* Pods-Popover_Tests.release.xcconfig */; - buildSettings = { - BUNDLE_LOADER = "$(TEST_HOST)"; FRAMEWORK_SEARCH_PATHS = ( - "$(SDKROOT)/Developer/Library/Frameworks", "$(inherited)", + "$(PROJECT_DIR)/build/Debug-iphoneos", ); - INFOPLIST_FILE = Tests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + INFOPLIST_FILE = Popover/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + MODULE_NAME = ExampleApp; PRODUCT_NAME = "$(TARGET_NAME)"; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Popover_Example.app/Popover_Example"; }; name = Release; }; @@ -554,7 +405,7 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 607FACEF1AFB9204008FA782 /* Build configuration list for PBXNativeTarget "Popover_Example" */ = { + 607FACEF1AFB9204008FA782 /* Build configuration list for PBXNativeTarget "PopoverExample" */ = { isa = XCConfigurationList; buildConfigurations = ( 607FACF01AFB9204008FA782 /* Debug */, @@ -563,15 +414,6 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 607FACF21AFB9204008FA782 /* Build configuration list for PBXNativeTarget "Popover_Tests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 607FACF31AFB9204008FA782 /* Debug */, - 607FACF41AFB9204008FA782 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; /* End XCConfigurationList section */ }; rootObject = 607FACC81AFB9204008FA782 /* Project object */; diff --git a/Example/Popover.xcodeproj/xcshareddata/xcschemes/Popover-Example.xcscheme b/Example/Popover.xcodeproj/xcshareddata/xcschemes/Popover-Example.xcscheme deleted file mode 100644 index 1406c4e..0000000 --- a/Example/Popover.xcodeproj/xcshareddata/xcschemes/Popover-Example.xcscheme +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Example/Popover.xcworkspace/contents.xcworkspacedata b/Example/Popover.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..9cdf5d3 --- /dev/null +++ b/Example/Popover.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/Example/Popover/AppDelegate.swift b/Example/Popover/AppDelegate.swift index cc8874e..f95c789 100644 --- a/Example/Popover/AppDelegate.swift +++ b/Example/Popover/AppDelegate.swift @@ -2,7 +2,7 @@ // AppDelegate.swift // Popover // -// Created by corin8823 on 08/16/2015. +// Created by corin8823 on 8/16/15. // Copyright (c) 2015 corin8823. All rights reserved. // @@ -11,36 +11,32 @@ import UIKit @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { - var window: UIWindow? + var window: UIWindow? + func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { + // Override point for customization after application launch. + return true + } - func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { - // Override point for customization after application launch. - return true - } + func applicationWillResignActive(application: UIApplication) { + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. + } - func applicationWillResignActive(application: UIApplication) { - // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. - // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. - } + func applicationDidEnterBackground(application: UIApplication) { + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. + } - func applicationDidEnterBackground(application: UIApplication) { - // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. - // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. - } + func applicationWillEnterForeground(application: UIApplication) { + // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. + } - func applicationWillEnterForeground(application: UIApplication) { - // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. - } - - func applicationDidBecomeActive(application: UIApplication) { - // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. - } - - func applicationWillTerminate(application: UIApplication) { - // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. - } - - -} + func applicationDidBecomeActive(application: UIApplication) { + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. + } + func applicationWillTerminate(application: UIApplication) { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. + } +} \ No newline at end of file diff --git a/Example/Popover/Base.lproj/Main.storyboard b/Example/Popover/Base.lproj/Main.storyboard index 52ea29e..426f32d 100644 --- a/Example/Popover/Base.lproj/Main.storyboard +++ b/Example/Popover/Base.lproj/Main.storyboard @@ -1,25 +1,96 @@ - + - + + - + - + - - + + - + - - + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + diff --git a/Example/Popover/Info.plist b/Example/Popover/Info.plist index 2960c1d..495ab4f 100644 --- a/Example/Popover/Info.plist +++ b/Example/Popover/Info.plist @@ -33,7 +33,6 @@ UISupportedInterfaceOrientations UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft diff --git a/Example/Popover/ViewController.swift b/Example/Popover/ViewController.swift index c54c247..a604434 100644 --- a/Example/Popover/ViewController.swift +++ b/Example/Popover/ViewController.swift @@ -2,23 +2,75 @@ // ViewController.swift // Popover // -// Created by corin8823 on 08/16/2015. +// Created by corin8823 on 8/16/15. // Copyright (c) 2015 corin8823. All rights reserved. // import UIKit +import Popover class ViewController: UIViewController { - override func viewDidLoad() { - super.viewDidLoad() - // Do any additional setup after loading the view, typically from a nib. - } + @IBOutlet weak var rightBarButton: UIBarButtonItem! + @IBOutlet weak var leftBottomButton: UIButton! + @IBOutlet weak var rightButtomButton: UIButton! - override func didReceiveMemoryWarning() { - super.didReceiveMemoryWarning() - // Dispose of any resources that can be recreated. - } + private var texts = ["Edit", "Delete", "Report"] + private var popover: Popover! + private var popoverOptions: [PopoverOption] = [ + .Type(.Up), + .BlackOverlayColor(UIColor(white: 0.0, alpha: 0.6)) + ] + + override func viewDidLoad() { + super.viewDidLoad() + } + + @IBAction func tappedRightBarButton(sender: UIBarButtonItem) { + let startPoint = CGPoint(x: self.view.frame.width - 60, y: 55) + let aView = UIView(frame: CGRect(x: 0, y: 0, width: self.view.frame.width, height: 180)) + var popover = Popover() + popover.show(aView, point: startPoint) + } + + @IBAction func tappedLeftBottomButton(sender: UIButton) { + let width = self.view.frame.width / 4 + let aView = UIView(frame: CGRect(x: 0, y: 0, width: width, height: width)) + let options = [ + .Type(.Up), + .CornerRadius(width / 2) + ] as [PopoverOption] + var popover = Popover(options: options, showHandler: nil, dismissHandler: nil) + popover.show(aView, fromView: self.leftBottomButton) + } + + @IBAction func tappedRightButtomButton(sender: UIButton) { + let tableView = UITableView(frame: CGRect(x: 0, y: 0, width: self.view.frame.width, height: 135)) + tableView.delegate = self + tableView.dataSource = self + tableView.scrollEnabled = false + self.popover = Popover(options: self.popoverOptions, showHandler: nil, dismissHandler: nil) + self.popover.show(tableView, fromView: self.rightButtomButton) + } } +extension ViewController: UITableViewDelegate { + + func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { + self.popover.dismiss() + } +} + +extension ViewController: UITableViewDataSource { + + func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int{ + return 3 + } + + func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { + let cell = UITableViewCell(style: .Default, reuseIdentifier: nil) + cell.textLabel?.text = self.texts[indexPath.row] + return cell + } +} \ No newline at end of file diff --git a/Example/Tests/Tests.swift b/Example/Tests/Tests.swift index b2f21ee..bcbc361 100644 --- a/Example/Tests/Tests.swift +++ b/Example/Tests/Tests.swift @@ -3,27 +3,27 @@ import XCTest import Popover class Tests: XCTestCase { - - override func setUp() { - super.setUp() - // Put setup code here. This method is called before the invocation of each test method in the class. - } - - override func tearDown() { - // Put teardown code here. This method is called after the invocation of each test method in the class. - super.tearDown() - } - - func testExample() { - // This is an example of a functional test case. - XCTAssert(true, "Pass") - } - - func testPerformanceExample() { - // This is an example of a performance test case. - self.measureBlock() { - // Put the code you want to measure the time of here. - } + + override func setUp() { + super.setUp() + // Put setup code here. This method is called before the invocation of each test method in the class. + } + + override func tearDown() { + // Put teardown code here. This method is called after the invocation of each test method in the class. + super.tearDown() + } + + func testExample() { + // This is an example of a functional test case. + XCTAssert(true, "Pass") + } + + func testPerformanceExample() { + // This is an example of a performance test case. + self.measureBlock() { + // Put the code you want to measure the time of here. } - + } + } diff --git a/Pod/Classes/.gitkeep b/Pod/Classes/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/Pod/Classes/ReplaceMe.swift b/Pod/Classes/ReplaceMe.swift deleted file mode 100644 index e69de29..0000000 diff --git a/Popover.podspec b/Popover.podspec index bfd483c..8b6a252 100644 --- a/Popover.podspec +++ b/Popover.podspec @@ -1,40 +1,16 @@ -# -# Be sure to run `pod lib lint Popover.podspec' to ensure this is a -# valid spec before submitting. -# -# Any lines starting with a # are optional, but their use is encouraged -# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html -# - Pod::Spec.new do |s| s.name = "Popover" - s.version = "0.1.0" - s.summary = "A short description of Popover." - -# This description is used to generate tags and improve search results. -# * Think: What does it do? Why did you write it? What is the focus? -# * Try to keep it short, snappy and to the point. -# * Write the description between the DESC delimiters below. -# * Finally, don't worry about the indent, CocoaPods strips it! - s.description = <<-DESC - DESC - - s.homepage = "https://github.com//Popover" + s.version = "0.0.1" + s.summary = "Popover is a boolloon library like facebook app." + s.homepage = "https://github.com/corin8823" # s.screenshots = "www.example.com/screenshots_1", "www.example.com/screenshots_2" - s.license = 'MIT' - s.author = { "corin8823" => "yusuke_takahashi@cyberagent.co.jp" } - s.source = { :git => "https://github.com//Popover.git", :tag => s.version.to_s } - # s.social_media_url = 'https://twitter.com/' + s.license = { :type => "MIT", :file => "LICENSE" } + s.author = { "corin8823" => "yusuke.t88@gmail.com" } + s.source = { :git => "https://github.com/corin8823/Popover.git", :tag => s.version.to_s } + s.social_media_url = 'https://twitter.com/corin8823' s.platform = :ios, '8.0' s.requires_arc = true - s.source_files = 'Pod/Classes/**/*' - s.resource_bundles = { - 'Popover' => ['Pod/Assets/*.png'] - } - - # s.public_header_files = 'Pod/Classes/**/*.h' - # s.frameworks = 'UIKit', 'MapKit' - # s.dependency 'AFNetworking', '~> 2.3' + s.source_files = 'Classes/*.swift' end diff --git a/README.md b/README.md index 8864a34..d48e9da 100644 --- a/README.md +++ b/README.md @@ -5,24 +5,59 @@ [![License](https://img.shields.io/cocoapods/l/Popover.svg?style=flat)](http://cocoapods.org/pods/Popover) [![Platform](https://img.shields.io/cocoapods/p/Popover.svg?style=flat)](http://cocoapods.org/pods/Popover) +## Description + ## Usage To run the example project, clone the repo, and run `pod install` from the Example directory first. +### Simple + +```swift +let startPoint = CGPoint(x: self.view.frame.width - 60, y: 55) +let aView = UIView(frame: CGRect(x: 0, y: 0, width: self.view.frame.width, height: 180)) +var popover = Popover() +popover.show(aView, point: startPoint) +``` + ## Requirements +- iOS 7.0+ ## Installation +### CocoaPods Popover is available through [CocoaPods](http://cocoapods.org). To install -it, simply add the following line to your Podfile: +it, simply add the following line to your `Podfile`: ```ruby pod "Popover" ``` +### Carthage (iOS 8+) +You can use [Carthage](https://github.com/Carthage/Carthage) to install `Popover` by adding it to your `Cartfile`: +``` +github "corin8823/Popover" +``` + +### Manual Installation +The class file required for Popover is located in the Classes folder in the root of this repository as listed below: +``` +Popover.swift +``` + +## Customization + +- ``case ArrowSize(CGSize)`` +- ``case AnimationIn(NSTimeInterval)`` +- ``case AnimationOut(NSTimeInterval)`` +- ``case CornerRadius(CGFloat)`` +- ``case SideEdge(CGFloat)`` +- ``case BlackOverlayColor(UIColor)`` +- ``case Type(Popover.PopoverType)`` + ## Author -corin8823, yusuke_takahashi@cyberagent.co.jp +corin8823, yusuke.t88@gmail.com ## License diff --git a/_Pods.xcodeproj b/_Pods.xcodeproj deleted file mode 120000 index 3c5a8e7..0000000 --- a/_Pods.xcodeproj +++ /dev/null @@ -1 +0,0 @@ -Example/Pods/Pods.xcodeproj \ No newline at end of file