Repository: beryu/CustomizableActionSheet
Branch: master
Commit: 37ac2ea69873
Files: 22
Total size: 68.9 KB
Directory structure:
gitextract_6e4rxpog/
├── .gitignore
├── CustomizableActionSheet/
│ ├── CustomizableActionSheet.h
│ ├── CustomizableActionSheet.swift
│ └── Info.plist
├── CustomizableActionSheet.podspec
├── CustomizableActionSheet.xcodeproj/
│ ├── project.pbxproj
│ ├── project.xcworkspace/
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata/
│ │ └── IDEWorkspaceChecks.plist
│ └── xcshareddata/
│ └── xcschemes/
│ └── CustomizableActionSheet.xcscheme
├── CustomizableActionSheetDemo/
│ ├── AppDelegate.swift
│ ├── Assets.xcassets/
│ │ ├── AppIcon.appiconset/
│ │ │ └── Contents.json
│ │ ├── Brand Assets.launchimage/
│ │ │ └── Contents.json
│ │ └── Contents.json
│ ├── Base.lproj/
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── Info.plist
│ ├── SampleView.swift
│ ├── SampleView.xib
│ └── ViewController.swift
├── LICENSE
├── README.md
└── Source/
└── CustomizableActionSheet.swift
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
./build/
./build-test/
xcuserdata/
*.xccheckout
*.gcno
================================================
FILE: CustomizableActionSheet/CustomizableActionSheet.h
================================================
//
// CustomizableActionSheet.h
// CustomizableActionSheet
//
// Created by beryu on 2016/04/22.
// Copyright © 2016年 blk. All rights reserved.
//
#import <UIKit/UIKit.h>
//! Project version number for CustomizableActionSheet.
FOUNDATION_EXPORT double CustomizableActionSheetVersionNumber;
//! Project version string for CustomizableActionSheet.
FOUNDATION_EXPORT const unsigned char CustomizableActionSheetVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <CustomizableActionSheet/PublicHeader.h>
================================================
FILE: CustomizableActionSheet/CustomizableActionSheet.swift
================================================
//
// CustomizableActionSheet.swift
// CustomizableActionSheet
//
// Created by Ryuta Kibe on 2015/12/22.
// Copyright 2015 blk. All rights reserved.
//
import UIKit
@objc public enum CustomizableActionSheetItemType: Int {
case button
case view
}
// Can't define CustomizableActionSheetItem as struct because Obj-C can't see struct definition.
public class CustomizableActionSheetItem: NSObject {
// MARK: - Public properties
public var type: CustomizableActionSheetItemType = .button
public var height: CGFloat = CustomizableActionSheetItem.kDefaultHeight
public static let kDefaultHeight: CGFloat = 44
// type = .View
public var view: UIView?
// type = .Button
public var label: String?
public var textColor: UIColor = UIColor(red: 0, green: 0.47, blue: 1.0, alpha: 1.0)
public var backgroundColor: UIColor = UIColor.white
public var font: UIFont? = nil
public var selectAction: ((_ actionSheet: CustomizableActionSheet) -> Void)? = nil
// MARK: - Private properties
fileprivate var element: UIView? = nil
public convenience init(type: CustomizableActionSheetItemType,
height: CGFloat = CustomizableActionSheetItem.kDefaultHeight) {
self.init()
self.type = type
self.height = height
}
}
private class ActionSheetItemView: UIView {
var subview: UIView?
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)!
self.setting()
}
override init(frame: CGRect) {
super.init(frame: frame)
self.setting()
}
init() {
super.init(frame: CGRect.zero)
self.setting()
}
func setting() {
self.clipsToBounds = true
}
override func addSubview(_ view: UIView) {
super.addSubview(view)
self.subview = view
}
override func layoutSubviews() {
super.layoutSubviews()
if let subview = self.subview {
subview.frame = self.bounds
}
}
}
@objc public enum CustomizableActionSheetPosition: Int {
case bottom
case top
}
public class CustomizableActionSheet: NSObject {
// MARK: - Private properties
private static var actionSheets = [CustomizableActionSheet]()
private static let kMarginSide: CGFloat = 8
private static let kItemInterval: CGFloat = 8
private static let kMarginTop: CGFloat = 20
private var items: [CustomizableActionSheetItem]?
private let maskView = UIView()
private let itemContainerView = UIView()
private var closeBlock: (() -> Void)?
// MARK: - Public properties
public var defaultCornerRadius: CGFloat = 4
public var position: CustomizableActionSheetPosition = .bottom
public func showInView(_ targetView: UIView, items: [CustomizableActionSheetItem], closeBlock: (() -> Void)? = nil) {
// Save instance to reaction until closing this sheet
CustomizableActionSheet.actionSheets.append(self)
let targetBounds = targetView.bounds
// Save closeBlock
self.closeBlock = closeBlock
// mask view
let maskViewTapGesture = UITapGestureRecognizer(target: self, action: #selector(CustomizableActionSheet.maskViewWasTapped))
self.maskView.addGestureRecognizer(maskViewTapGesture)
self.maskView.frame = targetBounds
self.maskView.backgroundColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.5)
targetView.addSubview(self.maskView)
// set items
for subview in self.itemContainerView.subviews {
subview.removeFromSuperview()
}
var currentPosition: CGFloat = 0
let safeAreaLeft: CGFloat
let safeAreaWidth: CGFloat
let safeAreaTop: CGFloat
let safeAreaBottom: CGFloat
if #available(iOS 11.0, *) {
safeAreaLeft = targetView.safeAreaInsets.left
safeAreaWidth = targetView.safeAreaLayoutGuide.layoutFrame.width
safeAreaTop = targetView.safeAreaInsets.top
safeAreaBottom = targetView.safeAreaInsets.bottom
} else {
safeAreaLeft = 0
safeAreaWidth = targetBounds.width
safeAreaTop = CustomizableActionSheet.kMarginTop
safeAreaBottom = 0
}
var availableHeight = targetBounds.height - safeAreaTop - safeAreaBottom
// Calculate height of items
for item in items {
availableHeight = availableHeight - item.height - CustomizableActionSheet.kItemInterval
}
for item in items {
// Apply height of items
if availableHeight < 0 {
let reduceNum = min(item.height, -availableHeight)
item.height -= reduceNum
availableHeight += reduceNum
if item.height <= 0 {
availableHeight += CustomizableActionSheet.kItemInterval
continue
}
}
// Add views
switch (item.type) {
case .button:
let button = UIButton()
button.layer.cornerRadius = defaultCornerRadius
button.frame = CGRect(
x: CustomizableActionSheet.kMarginSide,
y: currentPosition,
width: safeAreaWidth - (CustomizableActionSheet.kMarginSide * 2),
height: item.height)
button.setTitle(item.label, for: UIControl.State())
button.backgroundColor = item.backgroundColor
button.setTitleColor(item.textColor, for: UIControl.State())
if let font = item.font {
button.titleLabel?.font = font
}
if let _ = item.selectAction {
button.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(CustomizableActionSheet.buttonWasTapped(_:))))
}
item.element = button
self.itemContainerView.addSubview(button)
currentPosition = currentPosition + item.height + CustomizableActionSheet.kItemInterval
case .view:
if let view = item.view {
let containerView = ActionSheetItemView(frame: CGRect(
x: CustomizableActionSheet.kMarginSide,
y: currentPosition,
width: safeAreaWidth - (CustomizableActionSheet.kMarginSide * 2),
height: item.height))
containerView.layer.cornerRadius = defaultCornerRadius
containerView.addSubview(view)
view.frame = view.bounds
self.itemContainerView.addSubview(containerView)
item.element = view
currentPosition = currentPosition + item.height + CustomizableActionSheet.kItemInterval
}
}
}
let positionX: CGFloat = safeAreaLeft
var positionY: CGFloat = targetBounds.minY + targetBounds.height - currentPosition - safeAreaBottom
var moveY: CGFloat = positionY
if self.position == .top {
positionY = CustomizableActionSheet.kItemInterval
moveY = -currentPosition
}
self.itemContainerView.frame = CGRect(
x: positionX,
y: positionY,
width: safeAreaWidth,
height: currentPosition)
self.items = items
// Show animation
self.maskView.alpha = 0
targetView.addSubview(self.itemContainerView)
self.itemContainerView.transform = CGAffineTransform(translationX: 0, y: moveY)
UIView.animate(withDuration: 0.4,
delay: 0,
usingSpringWithDamping: 1,
initialSpringVelocity: 0,
options: .curveEaseOut,
animations: { () -> Void in
self.maskView.alpha = 1
self.itemContainerView.transform = CGAffineTransform.identity
}, completion: nil)
}
public func dismiss() {
guard let targetView = self.itemContainerView.superview else {
return
}
// Hide animation
self.maskView.alpha = 1
var moveY: CGFloat = targetView.bounds.height - self.itemContainerView.frame.origin.y
if self.position == .top {
moveY = -self.itemContainerView.frame.height
}
UIView.animate(withDuration: 0.2,
delay: 0,
usingSpringWithDamping: 1,
initialSpringVelocity: 0,
options: .curveEaseOut,
animations: { () -> Void in
self.maskView.alpha = 0
self.itemContainerView.transform = CGAffineTransform(translationX: 0, y: moveY)
}) { (result: Bool) -> Void in
// Remove views
self.itemContainerView.removeFromSuperview()
self.maskView.removeFromSuperview()
// Remove this instance
for i in 0 ..< CustomizableActionSheet.actionSheets.count {
if CustomizableActionSheet.actionSheets[i] == self {
CustomizableActionSheet.actionSheets.remove(at: i)
break
}
}
self.closeBlock?()
}
}
// MARK: - Private methods
@objc private func maskViewWasTapped() {
self.dismiss()
}
@objc private func buttonWasTapped(_ sender: AnyObject) {
guard let items = self.items else {
return
}
for item in items {
guard
let element = item.element,
let gestureRecognizer = sender as? UITapGestureRecognizer else {
continue
}
if element == gestureRecognizer.view {
item.selectAction?(self)
}
}
}
}
================================================
FILE: CustomizableActionSheet/Info.plist
================================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0.8</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
================================================
FILE: CustomizableActionSheet.podspec
================================================
Pod::Spec.new do |s|
s.name = "CustomizableActionSheet"
s.version = "1.2.3"
s.summary = "Action sheet allows including your custom views and buttons."
s.homepage = "https://github.com/beryu/CustomizableActionSheet"
s.screenshots = "https://github.com/beryu/CustomizableActionSheet/raw/master/assets/screenshot1.png"
s.license = { :type => "MIT", :file => "LICENSE" }
s.author = { "Ryuta Kibe" => "beryu@blk.jp" }
s.social_media_url = "https://twitter.com/beryu"
s.platform = :ios
s.ios.deployment_target = "8.0"
s.source = { :git => "https://github.com/beryu/CustomizableActionSheet.git", :tag => s.version }
s.source_files = "Source/*"
s.requires_arc = true
end
================================================
FILE: CustomizableActionSheet.xcodeproj/project.pbxproj
================================================
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
87B8409D1C27F3C100C84DCE /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 87B8409C1C27F3C100C84DCE /* AppDelegate.swift */; };
87B8409F1C27F3C100C84DCE /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 87B8409E1C27F3C100C84DCE /* ViewController.swift */; };
87B840A21C27F3C100C84DCE /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 87B840A01C27F3C100C84DCE /* Main.storyboard */; };
87B840A41C27F3C100C84DCE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 87B840A31C27F3C100C84DCE /* Assets.xcassets */; };
87B840A71C27F3C100C84DCE /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 87B840A51C27F3C100C84DCE /* LaunchScreen.storyboard */; };
8825BEE41CCA5E4B00F7A17D /* CustomizableActionSheet.h in Headers */ = {isa = PBXBuildFile; fileRef = 8825BEE31CCA5E4B00F7A17D /* CustomizableActionSheet.h */; settings = {ATTRIBUTES = (Public, ); }; };
8825BEE81CCA5E4B00F7A17D /* CustomizableActionSheet.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8825BEE11CCA5E4B00F7A17D /* CustomizableActionSheet.framework */; };
8825BEE91CCA5E4B00F7A17D /* CustomizableActionSheet.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 8825BEE11CCA5E4B00F7A17D /* CustomizableActionSheet.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
8825BEEF1CCA5E8400F7A17D /* CustomizableActionSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8825BEEE1CCA5E8400F7A17D /* CustomizableActionSheet.swift */; };
88FFDA211C30269D00FCBFF3 /* SampleView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 88FFDA201C30269D00FCBFF3 /* SampleView.xib */; };
88FFDA231C3031F200FCBFF3 /* SampleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88FFDA221C3031F200FCBFF3 /* SampleView.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
8825BEE61CCA5E4B00F7A17D /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 87B840911C27F3C100C84DCE /* Project object */;
proxyType = 1;
remoteGlobalIDString = 8825BEE01CCA5E4B00F7A17D;
remoteInfo = CustomizableActionSheet;
};
/* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */
8825BEED1CCA5E4B00F7A17D /* Embed Frameworks */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 10;
files = (
8825BEE91CCA5E4B00F7A17D /* CustomizableActionSheet.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
87B840991C27F3C100C84DCE /* CustomizableActionSheetDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CustomizableActionSheetDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
87B8409C1C27F3C100C84DCE /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
87B8409E1C27F3C100C84DCE /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
87B840A11C27F3C100C84DCE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
87B840A31C27F3C100C84DCE /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
87B840A61C27F3C100C84DCE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
87B840A81C27F3C100C84DCE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
8825BEE11CCA5E4B00F7A17D /* CustomizableActionSheet.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CustomizableActionSheet.framework; sourceTree = BUILT_PRODUCTS_DIR; };
8825BEE31CCA5E4B00F7A17D /* CustomizableActionSheet.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CustomizableActionSheet.h; sourceTree = "<group>"; };
8825BEE51CCA5E4B00F7A17D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
8825BEEE1CCA5E8400F7A17D /* CustomizableActionSheet.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomizableActionSheet.swift; sourceTree = "<group>"; };
88FFDA201C30269D00FCBFF3 /* SampleView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SampleView.xib; sourceTree = "<group>"; };
88FFDA221C3031F200FCBFF3 /* SampleView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SampleView.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
87B840961C27F3C100C84DCE /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
8825BEE81CCA5E4B00F7A17D /* CustomizableActionSheet.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
8825BEDD1CCA5E4B00F7A17D /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
87B840901C27F3C100C84DCE = {
isa = PBXGroup;
children = (
87B8409B1C27F3C100C84DCE /* CustomizableActionSheetDemo */,
8825BEE21CCA5E4B00F7A17D /* CustomizableActionSheet */,
87B8409A1C27F3C100C84DCE /* Products */,
);
sourceTree = "<group>";
};
87B8409A1C27F3C100C84DCE /* Products */ = {
isa = PBXGroup;
children = (
87B840991C27F3C100C84DCE /* CustomizableActionSheetDemo.app */,
8825BEE11CCA5E4B00F7A17D /* CustomizableActionSheet.framework */,
);
name = Products;
sourceTree = "<group>";
};
87B8409B1C27F3C100C84DCE /* CustomizableActionSheetDemo */ = {
isa = PBXGroup;
children = (
87B8409C1C27F3C100C84DCE /* AppDelegate.swift */,
87B8409E1C27F3C100C84DCE /* ViewController.swift */,
87B840A01C27F3C100C84DCE /* Main.storyboard */,
87B840A31C27F3C100C84DCE /* Assets.xcassets */,
87B840A51C27F3C100C84DCE /* LaunchScreen.storyboard */,
87B840A81C27F3C100C84DCE /* Info.plist */,
88FFDA201C30269D00FCBFF3 /* SampleView.xib */,
88FFDA221C3031F200FCBFF3 /* SampleView.swift */,
);
path = CustomizableActionSheetDemo;
sourceTree = "<group>";
};
8825BEE21CCA5E4B00F7A17D /* CustomizableActionSheet */ = {
isa = PBXGroup;
children = (
8825BEEE1CCA5E8400F7A17D /* CustomizableActionSheet.swift */,
8825BEE31CCA5E4B00F7A17D /* CustomizableActionSheet.h */,
8825BEE51CCA5E4B00F7A17D /* Info.plist */,
);
path = CustomizableActionSheet;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
8825BEDE1CCA5E4B00F7A17D /* Headers */ = {
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
8825BEE41CCA5E4B00F7A17D /* CustomizableActionSheet.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXHeadersBuildPhase section */
/* Begin PBXNativeTarget section */
87B840981C27F3C100C84DCE /* CustomizableActionSheetDemo */ = {
isa = PBXNativeTarget;
buildConfigurationList = 87B840AB1C27F3C100C84DCE /* Build configuration list for PBXNativeTarget "CustomizableActionSheetDemo" */;
buildPhases = (
87B840951C27F3C100C84DCE /* Sources */,
87B840961C27F3C100C84DCE /* Frameworks */,
87B840971C27F3C100C84DCE /* Resources */,
8825BEED1CCA5E4B00F7A17D /* Embed Frameworks */,
);
buildRules = (
);
dependencies = (
8825BEE71CCA5E4B00F7A17D /* PBXTargetDependency */,
);
name = CustomizableActionSheetDemo;
productName = CustomizableActionSheet;
productReference = 87B840991C27F3C100C84DCE /* CustomizableActionSheetDemo.app */;
productType = "com.apple.product-type.application";
};
8825BEE01CCA5E4B00F7A17D /* CustomizableActionSheet */ = {
isa = PBXNativeTarget;
buildConfigurationList = 8825BEEA1CCA5E4B00F7A17D /* Build configuration list for PBXNativeTarget "CustomizableActionSheet" */;
buildPhases = (
8825BEDC1CCA5E4B00F7A17D /* Sources */,
8825BEDD1CCA5E4B00F7A17D /* Frameworks */,
8825BEDE1CCA5E4B00F7A17D /* Headers */,
8825BEDF1CCA5E4B00F7A17D /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = CustomizableActionSheet;
productName = CustomizableActionSheet;
productReference = 8825BEE11CCA5E4B00F7A17D /* CustomizableActionSheet.framework */;
productType = "com.apple.product-type.framework";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
87B840911C27F3C100C84DCE /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 0800;
ORGANIZATIONNAME = blk;
TargetAttributes = {
87B840981C27F3C100C84DCE = {
CreatedOnToolsVersion = 7.2;
LastSwiftMigration = 0800;
};
8825BEE01CCA5E4B00F7A17D = {
CreatedOnToolsVersion = 7.3;
LastSwiftMigration = 0900;
};
};
};
buildConfigurationList = 87B840941C27F3C100C84DCE /* Build configuration list for PBXProject "CustomizableActionSheet" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 87B840901C27F3C100C84DCE;
productRefGroup = 87B8409A1C27F3C100C84DCE /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
87B840981C27F3C100C84DCE /* CustomizableActionSheetDemo */,
8825BEE01CCA5E4B00F7A17D /* CustomizableActionSheet */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
87B840971C27F3C100C84DCE /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
88FFDA211C30269D00FCBFF3 /* SampleView.xib in Resources */,
87B840A71C27F3C100C84DCE /* LaunchScreen.storyboard in Resources */,
87B840A41C27F3C100C84DCE /* Assets.xcassets in Resources */,
87B840A21C27F3C100C84DCE /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
8825BEDF1CCA5E4B00F7A17D /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
87B840951C27F3C100C84DCE /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
88FFDA231C3031F200FCBFF3 /* SampleView.swift in Sources */,
87B8409F1C27F3C100C84DCE /* ViewController.swift in Sources */,
87B8409D1C27F3C100C84DCE /* AppDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
8825BEDC1CCA5E4B00F7A17D /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
8825BEEF1CCA5E8400F7A17D /* CustomizableActionSheet.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
8825BEE71CCA5E4B00F7A17D /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 8825BEE01CCA5E4B00F7A17D /* CustomizableActionSheet */;
targetProxy = 8825BEE61CCA5E4B00F7A17D /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */
87B840A01C27F3C100C84DCE /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
87B840A11C27F3C100C84DCE /* Base */,
);
name = Main.storyboard;
sourceTree = "<group>";
};
87B840A51C27F3C100C84DCE /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
87B840A61C27F3C100C84DCE /* Base */,
);
name = LaunchScreen.storyboard;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
87B840A91C27F3C100C84DCE /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
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";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.2;
};
name = Debug;
};
87B840AA1C27F3C100C84DCE /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
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";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.2;
VALIDATE_PRODUCT = YES;
};
name = Release;
};
87B840AC1C27F3C100C84DCE /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = "Brand Assets";
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = CustomizableActionSheetDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = jp.blk.CustomizableActionSheetDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
};
name = Debug;
};
87B840AD1C27F3C100C84DCE /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = "Brand Assets";
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = CustomizableActionSheetDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = jp.blk.CustomizableActionSheetDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
};
name = Release;
};
8825BEEB1CCA5E4B00F7A17D /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ANALYZER_NONNULL = YES;
CLANG_ENABLE_MODULES = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = CustomizableActionSheet/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = jp.blk.CustomizableActionSheet;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
name = Debug;
};
8825BEEC1CCA5E4B00F7A17D /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ANALYZER_NONNULL = YES;
CLANG_ENABLE_MODULES = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = CustomizableActionSheet/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = jp.blk.CustomizableActionSheet;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
87B840941C27F3C100C84DCE /* Build configuration list for PBXProject "CustomizableActionSheet" */ = {
isa = XCConfigurationList;
buildConfigurations = (
87B840A91C27F3C100C84DCE /* Debug */,
87B840AA1C27F3C100C84DCE /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
87B840AB1C27F3C100C84DCE /* Build configuration list for PBXNativeTarget "CustomizableActionSheetDemo" */ = {
isa = XCConfigurationList;
buildConfigurations = (
87B840AC1C27F3C100C84DCE /* Debug */,
87B840AD1C27F3C100C84DCE /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
8825BEEA1CCA5E4B00F7A17D /* Build configuration list for PBXNativeTarget "CustomizableActionSheet" */ = {
isa = XCConfigurationList;
buildConfigurations = (
8825BEEB1CCA5E4B00F7A17D /* Debug */,
8825BEEC1CCA5E4B00F7A17D /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 87B840911C27F3C100C84DCE /* Project object */;
}
================================================
FILE: CustomizableActionSheet.xcodeproj/project.xcworkspace/contents.xcworkspacedata
================================================
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:CustomizableActionSheet.xcodeproj">
</FileRef>
</Workspace>
================================================
FILE: CustomizableActionSheet.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
================================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
================================================
FILE: CustomizableActionSheet.xcodeproj/xcshareddata/xcschemes/CustomizableActionSheet.xcscheme
================================================
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "8825BEE01CCA5E4B00F7A17D"
BuildableName = "CustomizableActionSheet.framework"
BlueprintName = "CustomizableActionSheet"
ReferencedContainer = "container:CustomizableActionSheet.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "8825BEE01CCA5E4B00F7A17D"
BuildableName = "CustomizableActionSheet.framework"
BlueprintName = "CustomizableActionSheet"
ReferencedContainer = "container:CustomizableActionSheet.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "8825BEE01CCA5E4B00F7A17D"
BuildableName = "CustomizableActionSheet.framework"
BlueprintName = "CustomizableActionSheet"
ReferencedContainer = "container:CustomizableActionSheet.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
================================================
FILE: CustomizableActionSheetDemo/AppDelegate.swift
================================================
//
// AppDelegate.swift
// CustomizableActionSheet
//
// Created by Ryuta Kibe on 2015/12/21.
// Copyright © 2015年 blk. All rights reserved.
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
private 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 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 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:.
}
}
================================================
FILE: CustomizableActionSheetDemo/Assets.xcassets/AppIcon.appiconset/Contents.json
================================================
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: CustomizableActionSheetDemo/Assets.xcassets/Brand Assets.launchimage/Contents.json
================================================
{
"images" : [
{
"orientation" : "portrait",
"idiom" : "iphone",
"extent" : "full-screen",
"minimum-system-version" : "8.0",
"subtype" : "736h",
"scale" : "3x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
"extent" : "full-screen",
"minimum-system-version" : "8.0",
"subtype" : "667h",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"subtype" : "retina4",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: CustomizableActionSheetDemo/Assets.xcassets/Contents.json
================================================
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: CustomizableActionSheetDemo/Base.lproj/LaunchScreen.storyboard
================================================
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9529"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>
================================================
FILE: CustomizableActionSheetDemo/Base.lproj/Main.storyboard
================================================
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11201" systemVersion="15G31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="CustomizableActionSheetDemo" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="3Vm-1d-32x">
<constraints>
<constraint firstAttribute="height" constant="44" id="oHm-TU-gl6"/>
<constraint firstAttribute="width" constant="300" id="yjW-Mq-kaH"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<state key="normal" title="Select color"/>
<connections>
<action selector="buttonShowWasTapped" destination="BYZ-38-t0r" eventType="touchUpInside" id="tD7-co-OYf"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="3Vm-1d-32x" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="RZu-15-nBG"/>
<constraint firstItem="3Vm-1d-32x" firstAttribute="centerY" secondItem="8bC-Xf-vdC" secondAttribute="centerY" id="bZd-tU-npe"/>
</constraints>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="317" y="429"/>
</scene>
</scenes>
</document>
================================================
FILE: CustomizableActionSheetDemo/Info.plist
================================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.8</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
</dict>
</plist>
================================================
FILE: CustomizableActionSheetDemo/SampleView.swift
================================================
//
// SampleView.swift
// CustomizableActionSheet
//
// Created by beryu on 2015/12/27.
// Copyright © 2015年 blk. All rights reserved.
//
import UIKit
@objc protocol SampleViewDelegate {
func setColor(color: UIColor)
}
class SampleView: UIView {
weak var delegate: SampleViewDelegate?
@IBAction func color1WasTapped() {
self.delegate?.setColor(color: UIColor(red: 0.89, green: 0.59, blue: 0.59, alpha: 1))
}
@IBAction func color2WasTapped() {
self.delegate?.setColor(color: UIColor(red: 0.88, green: 0.84, blue: 0.58, alpha: 1))
}
@IBAction func color3WasTapped() {
self.delegate?.setColor(color: UIColor(red: 0.81, green: 0.89, blue: 0.58, alpha: 1))
}
@IBAction func color4WasTapped() {
self.delegate?.setColor(color: UIColor(red: 0.58, green: 0.89, blue: 0.73, alpha: 1))
}
@IBAction func color5WasTapped() {
self.delegate?.setColor(color: UIColor(red: 0.58, green: 0.78, blue: 0.89, alpha: 1))
}
}
================================================
FILE: CustomizableActionSheetDemo/SampleView.xib
================================================
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11201" systemVersion="15G31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="iN0-l3-epB" customClass="SampleView" customModule="CustomizableActionSheetDemo" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Set color" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="EdZ-0p-uai">
<constraints>
<constraint firstAttribute="height" constant="40" id="bFh-MX-gka"/>
</constraints>
<fontDescription key="fontDescription" name="Arial-BoldMT" family="Arial" pointSize="15"/>
<color key="textColor" red="0.33333333333333331" green="0.33333333333333331" blue="0.33333333333333331" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="yAg-gW-tYs">
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="NFN-Un-Ueo">
<color key="backgroundColor" red="0.89411764705882346" green="0.59607843137254901" blue="0.59215686274509804" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="width" constant="44" id="eHM-bg-Awh"/>
<constraint firstAttribute="height" constant="44" id="fPw-Uh-gtM"/>
</constraints>
<connections>
<action selector="color1WasTapped" destination="iN0-l3-epB" eventType="touchUpInside" id="GEY-Tc-Fpl"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="WV1-mg-w81">
<color key="backgroundColor" red="0.88627450980392153" green="0.84313725490196079" blue="0.58039215686274503" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="width" constant="44" id="QPQ-Yt-eYa"/>
<constraint firstAttribute="height" constant="44" id="TS2-7v-p3H"/>
</constraints>
<connections>
<action selector="color2WasTapped" destination="iN0-l3-epB" eventType="touchUpInside" id="rdc-NQ-23e"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="5s7-b0-S3M">
<color key="backgroundColor" red="0.81568627450980391" green="0.8901960784313725" blue="0.58039215686274503" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="44" id="2L8-RN-dvp"/>
<constraint firstAttribute="width" constant="44" id="wah-Ar-gID"/>
</constraints>
<connections>
<action selector="color3WasTapped" destination="iN0-l3-epB" eventType="touchUpInside" id="M51-b6-nOC"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="yiT-CS-ZLL">
<color key="backgroundColor" red="0.58823529411764708" green="0.8901960784313725" blue="0.73725490196078436" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="width" constant="44" id="bxR-dg-33J"/>
<constraint firstAttribute="height" constant="44" id="vWe-hQ-JXC"/>
</constraints>
<connections>
<action selector="color4WasTapped" destination="iN0-l3-epB" eventType="touchUpInside" id="Fmc-K3-XJ0"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="a1r-ur-6Xl">
<color key="backgroundColor" red="0.58823529411764708" green="0.78823529411764703" blue="0.8901960784313725" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="width" constant="44" id="G7I-KK-Uas"/>
<constraint firstAttribute="height" constant="44" id="Q6G-uE-r8v"/>
</constraints>
<connections>
<action selector="color5WasTapped" destination="iN0-l3-epB" eventType="touchUpInside" id="HVb-Ey-5Do"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="WV1-mg-w81" firstAttribute="leading" secondItem="NFN-Un-Ueo" secondAttribute="trailing" constant="8" id="E4K-hq-oft"/>
<constraint firstItem="yiT-CS-ZLL" firstAttribute="top" secondItem="yAg-gW-tYs" secondAttribute="top" id="GvR-5K-OhB"/>
<constraint firstItem="WV1-mg-w81" firstAttribute="top" secondItem="yAg-gW-tYs" secondAttribute="top" id="LHe-L1-kSF"/>
<constraint firstItem="yiT-CS-ZLL" firstAttribute="leading" secondItem="5s7-b0-S3M" secondAttribute="trailing" constant="8" id="RA9-Er-Zd2"/>
<constraint firstAttribute="width" constant="260" id="Xwm-Gg-vBX"/>
<constraint firstItem="a1r-ur-6Xl" firstAttribute="leading" secondItem="yiT-CS-ZLL" secondAttribute="trailing" constant="8" id="a2G-PB-4af"/>
<constraint firstItem="5s7-b0-S3M" firstAttribute="top" secondItem="yAg-gW-tYs" secondAttribute="top" id="ecj-It-Y4e"/>
<constraint firstItem="5s7-b0-S3M" firstAttribute="leading" secondItem="WV1-mg-w81" secondAttribute="trailing" constant="8" id="gSQ-lI-Cmr"/>
<constraint firstItem="NFN-Un-Ueo" firstAttribute="top" secondItem="yAg-gW-tYs" secondAttribute="top" id="ib5-WR-nTI"/>
<constraint firstAttribute="height" constant="44" id="p0q-hF-Cwo"/>
<constraint firstItem="NFN-Un-Ueo" firstAttribute="leading" secondItem="yAg-gW-tYs" secondAttribute="leading" id="uaT-3J-0ro"/>
<constraint firstItem="a1r-ur-6Xl" firstAttribute="top" secondItem="yAg-gW-tYs" secondAttribute="top" id="vVL-tm-yXV"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="EdZ-0p-uai" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="1rE-sM-pbg"/>
<constraint firstAttribute="trailing" secondItem="EdZ-0p-uai" secondAttribute="trailing" id="Tow-b9-c1c"/>
<constraint firstItem="yAg-gW-tYs" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="lEY-d4-QDZ"/>
<constraint firstItem="EdZ-0p-uai" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="llj-dQ-3UR"/>
<constraint firstItem="yAg-gW-tYs" firstAttribute="top" secondItem="EdZ-0p-uai" secondAttribute="bottom" id="uXi-B4-J2y"/>
</constraints>
<nil key="simulatedStatusBarMetrics"/>
</view>
</objects>
</document>
================================================
FILE: CustomizableActionSheetDemo/ViewController.swift
================================================
//
// ViewController.swift
// CustomizableActionSheet
//
// Created by Ryuta Kibe on 2015/12/21.
// Copyright © 2015年 blk. All rights reserved.
//
import UIKit
import CustomizableActionSheet
class ViewController: UIViewController {
var actionSheet: CustomizableActionSheet?
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func buttonShowWasTapped() {
var items = [CustomizableActionSheetItem]()
// First view
if let sampleView = UINib(nibName: "SampleView", bundle: nil).instantiate(withOwner: self, options: nil)[0] as? SampleView {
sampleView.delegate = self
let sampleViewItem = CustomizableActionSheetItem(type: .view, height: 100)
sampleViewItem.view = sampleView
items.append(sampleViewItem)
}
// Second button
let clearItem = CustomizableActionSheetItem(type: .button)
clearItem.label = "Clear color"
clearItem.backgroundColor = UIColor(red: 1, green: 0.41, blue: 0.38, alpha: 1)
clearItem.textColor = UIColor.white
clearItem.selectAction = { (actionSheet: CustomizableActionSheet) -> Void in
self.view.backgroundColor = UIColor.white
actionSheet.dismiss()
}
items.append(clearItem)
// Third button
let closeItem = CustomizableActionSheetItem(type: .button)
closeItem.label = "Close"
closeItem.textColor = UIColor(red: 0.4, green: 0.4, blue: 0.4, alpha: 1)
closeItem.selectAction = { (actionSheet: CustomizableActionSheet) -> Void in
actionSheet.dismiss()
}
items.append(closeItem)
let actionSheet = CustomizableActionSheet()
self.actionSheet = actionSheet
actionSheet.showInView(self.view, items: items)
}
}
extension ViewController: SampleViewDelegate {
func setColor(color: UIColor) {
if let actionSheet = self.actionSheet {
actionSheet.dismiss()
}
self.view.backgroundColor = color
}
}
================================================
FILE: LICENSE
================================================
The MIT License (MIT)
Copyright (c) 2015 Ryuta Kibe (beryu@blk.jp)
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.
================================================
FILE: README.md
================================================
# CustomizableActionSheet



[](https://github.com/Carthage/Carthage)
Action sheet allows including your custom views and buttons.

## Installation
### CocoaPods
1. Edit your Podfile:
```ruby
pod 'CustomizableActionSheet'
```
2. Run `pod install`
#### Carthage
1. Edit your Cartfile:
```
github "beryu/CustomizableActionSheet"
```
2. Run `carthage update`
for more info, see [Carthage](https://github.com/carthage/carthage)
### Manually
Add the [CustomizableActionSheet.swift](https://github.com/beryu/CustomizableActionSheet/blob/master/Source/CustomizableActionSheet.swift) file to your project.
## Usage
```swift
var items = [CustomizableActionSheetItem]()
// Setup custom view
if let sampleView = UINib(nibName: "SampleView", bundle: nil).instantiateWithOwner(self, options: nil)[0] as? SampleView {
let sampleViewItem = CustomizableActionSheetItem()
sampleViewItem.type = .view
sampleViewItem.view = sampleView
sampleViewItem.height = 100
items.append(sampleViewItem)
}
// Setup button
let closeItem = CustomizableActionSheetItem()
closeItem.type = .button
closeItem.label = "Close"
closeItem.selectAction = { (actionSheet: CustomizableActionSheet) -> Void in
actionSheet.dismiss()
}
items.append(closeItem)
// Show
let actionSheet = CustomizableActionSheet()
actionSheet.showInView(self.view, items: items)
```
You can change the positioning of the action sheet from the bottom to the top of the view as follows:
```swift
actionSheet.position = .top
```
NOTE: If you have installed via CocoaPods, please import `CustomizableActionSheet` like below.
```swift
import CustomizableActionSheet
```
## Requirements
* Swift4.0
* iOS 8.0
* ARC
If you want to use even iOS7.0, please to import the code directly.
## License
The MIT License (MIT)
Copyright (c) 2015 Ryuta Kibe (beryu@blk.jp)
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.
================================================
FILE: Source/CustomizableActionSheet.swift
================================================
//
// CustomizableActionSheet.swift
// CustomizableActionSheet
//
// Created by Ryuta Kibe on 2015/12/22.
// Copyright 2015 blk. All rights reserved.
//
import UIKit
@objc public enum CustomizableActionSheetItemType: Int {
case button
case view
}
// Can't define CustomizableActionSheetItem as struct because Obj-C can't see struct definition.
public class CustomizableActionSheetItem: NSObject {
// MARK: - Public properties
public var type: CustomizableActionSheetItemType = .button
public var height: CGFloat = CustomizableActionSheetItem.kDefaultHeight
public static let kDefaultHeight: CGFloat = 44
// type = .View
public var view: UIView?
// type = .Button
public var label: String?
public var textColor: UIColor = UIColor(red: 0, green: 0.47, blue: 1.0, alpha: 1.0)
public var backgroundColor: UIColor = UIColor.white
public var font: UIFont? = nil
public var selectAction: ((_ actionSheet: CustomizableActionSheet) -> Void)? = nil
// MARK: - Private properties
fileprivate var element: UIView? = nil
public convenience init(type: CustomizableActionSheetItemType,
height: CGFloat = CustomizableActionSheetItem.kDefaultHeight) {
self.init()
self.type = type
self.height = height
}
}
private class ActionSheetItemView: UIView {
var subview: UIView?
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)!
self.setting()
}
override init(frame: CGRect) {
super.init(frame: frame)
self.setting()
}
init() {
super.init(frame: CGRect.zero)
self.setting()
}
func setting() {
self.clipsToBounds = true
}
override func addSubview(_ view: UIView) {
super.addSubview(view)
self.subview = view
}
override func layoutSubviews() {
super.layoutSubviews()
if let subview = self.subview {
subview.frame = self.bounds
}
}
}
@objc public enum CustomizableActionSheetPosition: Int {
case bottom
case top
}
public class CustomizableActionSheet: NSObject {
// MARK: - Private properties
private static var actionSheets = [CustomizableActionSheet]()
private static let kMarginSide: CGFloat = 8
private static let kItemInterval: CGFloat = 8
private static let kMarginTop: CGFloat = 20
private var items: [CustomizableActionSheetItem]?
private let maskView = UIView()
private let itemContainerView = UIView()
private var closeBlock: (() -> Void)?
// MARK: - Public properties
public var defaultCornerRadius: CGFloat = 4
public var position: CustomizableActionSheetPosition = .bottom
public func showInView(_ targetView: UIView, items: [CustomizableActionSheetItem], closeBlock: (() -> Void)? = nil) {
// Save instance to reaction until closing this sheet
CustomizableActionSheet.actionSheets.append(self)
let targetBounds = targetView.bounds
// Save closeBlock
self.closeBlock = closeBlock
// mask view
let maskViewTapGesture = UITapGestureRecognizer(target: self, action: #selector(CustomizableActionSheet.maskViewWasTapped))
self.maskView.addGestureRecognizer(maskViewTapGesture)
self.maskView.frame = targetBounds
self.maskView.backgroundColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.5)
targetView.addSubview(self.maskView)
// set items
for subview in self.itemContainerView.subviews {
subview.removeFromSuperview()
}
var currentPosition: CGFloat = 0
let safeAreaLeft: CGFloat
let safeAreaWidth: CGFloat
let safeAreaTop: CGFloat
let safeAreaBottom: CGFloat
if #available(iOS 11.0, *) {
safeAreaLeft = targetView.safeAreaInsets.left
safeAreaWidth = targetView.safeAreaLayoutGuide.layoutFrame.width
safeAreaTop = targetView.safeAreaInsets.top
safeAreaBottom = targetView.safeAreaInsets.bottom
} else {
safeAreaLeft = 0
safeAreaWidth = targetBounds.width
safeAreaTop = CustomizableActionSheet.kMarginTop
safeAreaBottom = 0
}
var availableHeight = targetBounds.height - safeAreaTop - safeAreaBottom
// Calculate height of items
for item in items {
availableHeight = availableHeight - item.height - CustomizableActionSheet.kItemInterval
}
for item in items {
// Apply height of items
if availableHeight < 0 {
let reduceNum = min(item.height, -availableHeight)
item.height -= reduceNum
availableHeight += reduceNum
if item.height <= 0 {
availableHeight += CustomizableActionSheet.kItemInterval
continue
}
}
// Add views
switch (item.type) {
case .button:
let button = UIButton()
button.layer.cornerRadius = defaultCornerRadius
button.frame = CGRect(
x: CustomizableActionSheet.kMarginSide,
y: currentPosition,
width: safeAreaWidth - (CustomizableActionSheet.kMarginSide * 2),
height: item.height)
button.setTitle(item.label, for: UIControl.State())
button.backgroundColor = item.backgroundColor
button.setTitleColor(item.textColor, for: UIControl.State())
if let font = item.font {
button.titleLabel?.font = font
}
if let _ = item.selectAction {
button.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(CustomizableActionSheet.buttonWasTapped(_:))))
}
item.element = button
self.itemContainerView.addSubview(button)
currentPosition = currentPosition + item.height + CustomizableActionSheet.kItemInterval
case .view:
if let view = item.view {
let containerView = ActionSheetItemView(frame: CGRect(
x: CustomizableActionSheet.kMarginSide,
y: currentPosition,
width: safeAreaWidth - (CustomizableActionSheet.kMarginSide * 2),
height: item.height))
containerView.layer.cornerRadius = defaultCornerRadius
containerView.addSubview(view)
view.frame = view.bounds
self.itemContainerView.addSubview(containerView)
item.element = view
currentPosition = currentPosition + item.height + CustomizableActionSheet.kItemInterval
}
}
}
let positionX: CGFloat = safeAreaLeft
var positionY: CGFloat = targetBounds.minY + targetBounds.height - currentPosition - safeAreaBottom
var moveY: CGFloat = positionY
if self.position == .top {
positionY = CustomizableActionSheet.kItemInterval
moveY = -currentPosition
}
self.itemContainerView.frame = CGRect(
x: positionX,
y: positionY,
width: safeAreaWidth,
height: currentPosition)
self.items = items
// Show animation
self.maskView.alpha = 0
targetView.addSubview(self.itemContainerView)
self.itemContainerView.transform = CGAffineTransform(translationX: 0, y: moveY)
UIView.animate(withDuration: 0.4,
delay: 0,
usingSpringWithDamping: 1,
initialSpringVelocity: 0,
options: .curveEaseOut,
animations: { () -> Void in
self.maskView.alpha = 1
self.itemContainerView.transform = CGAffineTransform.identity
}, completion: nil)
}
public func dismiss() {
guard let targetView = self.itemContainerView.superview else {
return
}
// Hide animation
self.maskView.alpha = 1
var moveY: CGFloat = targetView.bounds.height - self.itemContainerView.frame.origin.y
if self.position == .top {
moveY = -self.itemContainerView.frame.height
}
UIView.animate(withDuration: 0.2,
delay: 0,
usingSpringWithDamping: 1,
initialSpringVelocity: 0,
options: .curveEaseOut,
animations: { () -> Void in
self.maskView.alpha = 0
self.itemContainerView.transform = CGAffineTransform(translationX: 0, y: moveY)
}) { (result: Bool) -> Void in
// Remove views
self.itemContainerView.removeFromSuperview()
self.maskView.removeFromSuperview()
// Remove this instance
for i in 0 ..< CustomizableActionSheet.actionSheets.count {
if CustomizableActionSheet.actionSheets[i] == self {
CustomizableActionSheet.actionSheets.remove(at: i)
break
}
}
self.closeBlock?()
}
}
// MARK: - Private methods
@objc private func maskViewWasTapped() {
self.dismiss()
}
@objc private func buttonWasTapped(_ sender: AnyObject) {
guard let items = self.items else {
return
}
for item in items {
guard
let element = item.element,
let gestureRecognizer = sender as? UITapGestureRecognizer else {
continue
}
if element == gestureRecognizer.view {
item.selectAction?(self)
}
}
}
}
gitextract_6e4rxpog/
├── .gitignore
├── CustomizableActionSheet/
│ ├── CustomizableActionSheet.h
│ ├── CustomizableActionSheet.swift
│ └── Info.plist
├── CustomizableActionSheet.podspec
├── CustomizableActionSheet.xcodeproj/
│ ├── project.pbxproj
│ ├── project.xcworkspace/
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata/
│ │ └── IDEWorkspaceChecks.plist
│ └── xcshareddata/
│ └── xcschemes/
│ └── CustomizableActionSheet.xcscheme
├── CustomizableActionSheetDemo/
│ ├── AppDelegate.swift
│ ├── Assets.xcassets/
│ │ ├── AppIcon.appiconset/
│ │ │ └── Contents.json
│ │ ├── Brand Assets.launchimage/
│ │ │ └── Contents.json
│ │ └── Contents.json
│ ├── Base.lproj/
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── Info.plist
│ ├── SampleView.swift
│ ├── SampleView.xib
│ └── ViewController.swift
├── LICENSE
├── README.md
└── Source/
└── CustomizableActionSheet.swift
Condensed preview — 22 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (77K chars).
[
{
"path": ".gitignore",
"chars": 55,
"preview": "./build/\n./build-test/\nxcuserdata/\n*.xccheckout\n*.gcno\n"
},
{
"path": "CustomizableActionSheet/CustomizableActionSheet.h",
"chars": 583,
"preview": "//\n// CustomizableActionSheet.h\n// CustomizableActionSheet\n//\n// Created by beryu on 2016/04/22.\n// Copyright © 2016"
},
{
"path": "CustomizableActionSheet/CustomizableActionSheet.swift",
"chars": 8806,
"preview": "//\n// CustomizableActionSheet.swift\n// CustomizableActionSheet\n//\n// Created by Ryuta Kibe on 2015/12/22.\n// Copyrig"
},
{
"path": "CustomizableActionSheet/Info.plist",
"chars": 808,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/P"
},
{
"path": "CustomizableActionSheet.podspec",
"chars": 690,
"preview": "Pod::Spec.new do |s|\n s.name = \"CustomizableActionSheet\"\n s.version = \"1.2.3\"\n s.summary = \"Action sheet allows inclu"
},
{
"path": "CustomizableActionSheet.xcodeproj/project.pbxproj",
"chars": 19996,
"preview": "// !$*UTF8*$!\n{\n\tarchiveVersion = 1;\n\tclasses = {\n\t};\n\tobjectVersion = 46;\n\tobjects = {\n\n/* Begin PBXBuildFile section *"
},
{
"path": "CustomizableActionSheet.xcodeproj/project.xcworkspace/contents.xcworkspacedata",
"chars": 168,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Workspace\n version = \"1.0\">\n <FileRef\n location = \"self:CustomizableAct"
},
{
"path": "CustomizableActionSheet.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist",
"chars": 238,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/P"
},
{
"path": "CustomizableActionSheet.xcodeproj/xcshareddata/xcschemes/CustomizableActionSheet.xcscheme",
"chars": 2994,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Scheme\n LastUpgradeVersion = \"0800\"\n version = \"1.3\">\n <BuildAction\n "
},
{
"path": "CustomizableActionSheetDemo/AppDelegate.swift",
"chars": 2170,
"preview": "//\n// AppDelegate.swift\n// CustomizableActionSheet\n//\n// Created by Ryuta Kibe on 2015/12/21.\n// Copyright © 2015年 b"
},
{
"path": "CustomizableActionSheetDemo/Assets.xcassets/AppIcon.appiconset/Contents.json",
"chars": 848,
"preview": "{\n \"images\" : [\n {\n \"idiom\" : \"iphone\",\n \"size\" : \"20x20\",\n \"scale\" : \"2x\"\n },\n {\n \"idiom\""
},
{
"path": "CustomizableActionSheetDemo/Assets.xcassets/Brand Assets.launchimage/Contents.json",
"chars": 826,
"preview": "{\n \"images\" : [\n {\n \"orientation\" : \"portrait\",\n \"idiom\" : \"iphone\",\n \"extent\" : \"full-screen\",\n "
},
{
"path": "CustomizableActionSheetDemo/Assets.xcassets/Contents.json",
"chars": 62,
"preview": "{\n \"info\" : {\n \"version\" : 1,\n \"author\" : \"xcode\"\n }\n}"
},
{
"path": "CustomizableActionSheetDemo/Base.lproj/LaunchScreen.storyboard",
"chars": 1663,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<document type=\"com.apple.InterfaceBuilder3.CocoaTouch.Storyboard"
},
{
"path": "CustomizableActionSheetDemo/Base.lproj/Main.storyboard",
"chars": 3314,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<document type=\"com.apple.InterfaceBuilder3.CocoaTouch.Storyboard"
},
{
"path": "CustomizableActionSheetDemo/Info.plist",
"chars": 1096,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/P"
},
{
"path": "CustomizableActionSheetDemo/SampleView.swift",
"chars": 968,
"preview": "//\n// SampleView.swift\n// CustomizableActionSheet\n//\n// Created by beryu on 2015/12/27.\n// Copyright © 2015年 blk. Al"
},
{
"path": "CustomizableActionSheetDemo/SampleView.xib",
"chars": 10049,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<document type=\"com.apple.InterfaceBuilder3.CocoaTouch.XIB\" versi"
},
{
"path": "CustomizableActionSheetDemo/ViewController.swift",
"chars": 2031,
"preview": "//\n// ViewController.swift\n// CustomizableActionSheet\n//\n// Created by Ryuta Kibe on 2015/12/21.\n// Copyright © 2015"
},
{
"path": "LICENSE",
"chars": 1092,
"preview": "The MIT License (MIT)\n\nCopyright (c) 2015 Ryuta Kibe (beryu@blk.jp)\n\nPermission is hereby granted, free of charge, to an"
},
{
"path": "README.md",
"chars": 3249,
"preview": "# CustomizableActionSheet\n\n![Licen"
},
{
"path": "Source/CustomizableActionSheet.swift",
"chars": 8806,
"preview": "//\n// CustomizableActionSheet.swift\n// CustomizableActionSheet\n//\n// Created by Ryuta Kibe on 2015/12/22.\n// Copyrig"
}
]
About this extraction
This page contains the full source code of the beryu/CustomizableActionSheet GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 22 files (68.9 KB), approximately 19.9k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.