mirror of
https://github.com/nerdycat/Cupcake.git
synced 2024-09-11 04:55:33 +03:00
small fixes
This commit is contained in:
parent
2fd2659bc8
commit
64ecce1a5a
@ -175,7 +175,7 @@
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastSwiftUpdateCheck = 0820;
|
||||
LastUpgradeCheck = 0820;
|
||||
LastUpgradeCheck = 0910;
|
||||
ORGANIZATIONNAME = nerdycat;
|
||||
TargetAttributes = {
|
||||
841B2C6D1E7BC5900084B37C = {
|
||||
@ -281,7 +281,9 @@
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
@ -289,7 +291,11 @@
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
@ -330,7 +336,9 @@
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
@ -338,7 +346,11 @@
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
@ -373,7 +385,7 @@
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "nerdycat.Cupcake-Demo";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_VERSION = 4.0;
|
||||
TARGETED_DEVICE_FAMILY = 1;
|
||||
};
|
||||
name = Debug;
|
||||
@ -388,7 +400,7 @@
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "nerdycat.Cupcake-Demo";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_VERSION = 4.0;
|
||||
TARGETED_DEVICE_FAMILY = 1;
|
||||
};
|
||||
name = Release;
|
||||
|
Binary file not shown.
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0820"
|
||||
LastUpgradeVersion = "0910"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
@ -26,6 +26,7 @@
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
language = ""
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
</Testables>
|
||||
@ -45,6 +46,7 @@
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
language = ""
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
|
@ -28,7 +28,7 @@ class AppStoreCell: UITableViewCell {
|
||||
ratingLabel.text = result
|
||||
|
||||
let price = app["price"] as! String
|
||||
actionButton.str( price.characters.count > 0 ? "$" + price : "GET")
|
||||
actionButton.str( price.count > 0 ? "$" + price : "GET")
|
||||
}
|
||||
|
||||
func setupUI() {
|
||||
|
@ -41,7 +41,7 @@ class EnhancementViewController: BaseViewController {
|
||||
make.width.equal(nameField)
|
||||
|
||||
}).onChange({ [unowned self] codeField in
|
||||
if codeField.text?.characters.count == 4 {
|
||||
if codeField.text?.count == 4 {
|
||||
self.view.viewWithTag(101)?.becomeFirstResponder()
|
||||
}
|
||||
})
|
||||
|
@ -1,7 +1,7 @@
|
||||
Pod::Spec.new do |s|
|
||||
|
||||
s.name = "Cupcake"
|
||||
s.version = "1.2.0"
|
||||
s.version = "1.2.1"
|
||||
s.summary = "An easy way to create and layout UI components for iOS."
|
||||
|
||||
s.description = <<-DESC
|
||||
|
@ -65,8 +65,7 @@ public func Color(_ any: Any?) -> UIColor? {
|
||||
|
||||
//system color
|
||||
if let color = UIColor.cpk_safePerform(selector: sel) as? UIColor {
|
||||
return color.withAlphaComponent(alpha)
|
||||
|
||||
return (alpha == 1 ? color : color.withAlphaComponent(alpha))
|
||||
}
|
||||
|
||||
if string == "random" {
|
||||
@ -75,12 +74,12 @@ public func Color(_ any: Any?) -> UIColor? {
|
||||
b = Int(arc4random_uniform(256))
|
||||
|
||||
} else if string.hasPrefix("#") {
|
||||
if string.characters.count == 4 {
|
||||
if string.cpk_length() == 4 {
|
||||
r = Int(string.subAt(1), radix:16)! * 17
|
||||
g = Int(string.subAt(2), radix:16)! * 17
|
||||
b = Int(string.subAt(3), radix:16)! * 17
|
||||
|
||||
} else if string.characters.count == 7 {
|
||||
} else if string.cpk_length() == 7 {
|
||||
r = Int(string.subAt(1...2), radix:16)
|
||||
g = Int(string.subAt(3...4), radix:16)
|
||||
b = Int(string.subAt(5...6), radix:16)
|
||||
|
@ -34,7 +34,7 @@ public extension String {
|
||||
*/
|
||||
@discardableResult public func subFrom(_ indexOrSubstring: Any) -> String {
|
||||
if var index = indexOrSubstring as? Int {
|
||||
if index < 0 { index += self.characters.count }
|
||||
if index < 0 { index += self.cpk_length() }
|
||||
let from = self.index(self.startIndex, offsetBy: index)
|
||||
return self.cpk_substring(from: from)
|
||||
|
||||
@ -57,7 +57,7 @@ public extension String {
|
||||
*/
|
||||
@discardableResult public func subTo(_ indexOrSubstring: Any) -> String {
|
||||
if var index = indexOrSubstring as? Int {
|
||||
if index < 0 { index += self.characters.count }
|
||||
if index < 0 { index += self.cpk_length() }
|
||||
let to = self.index(self.startIndex, offsetBy: index)
|
||||
return self.cpk_substring(to: to)
|
||||
|
||||
@ -127,7 +127,7 @@ public extension String {
|
||||
|
||||
let matchRange = exp.rangeOfFirstMatch(in: self,
|
||||
options:options,
|
||||
range: NSMakeRange(0, self.characters.count))
|
||||
range: NSMakeRange(0, self.cpk_length()))
|
||||
|
||||
if matchRange.location != NSNotFound {
|
||||
return self.subAt(matchRange)
|
||||
@ -152,7 +152,7 @@ public extension String {
|
||||
|
||||
return exp.stringByReplacingMatches(in: self,
|
||||
options: options,
|
||||
range: NSMakeRange(0, self.characters.count),
|
||||
range: NSMakeRange(0, self.cpk_length()),
|
||||
withTemplate: template)
|
||||
}
|
||||
|
||||
|
@ -82,20 +82,27 @@ public extension UIView {
|
||||
}
|
||||
|
||||
/**
|
||||
* Drop shadow with opacity, radius (optional) and offset (optional).
|
||||
* Drop shadow with opacity, radius (optional), offset (optional) and color (optional).
|
||||
* shadow's color argument use Color() internally, so it can take any kind of values that Color() supported.
|
||||
* See Color.swift for more information.
|
||||
* Usages:
|
||||
.shadow(1)
|
||||
.shadow(0.7, 2)
|
||||
.shadow(0.7, 3, 0, 0)
|
||||
.shadow(0.7, 3, 0, 0, "red")
|
||||
*/
|
||||
@objc @discardableResult public func shadow(_ shadowOpacity: CGFloat,
|
||||
_ shadowRadius: CGFloat = 3,
|
||||
_ shadowOffsetX: CGFloat = 0,
|
||||
_ shadowOffsetY: CGFloat = 3) -> Self {
|
||||
_ shadowOffsetY: CGFloat = 3,
|
||||
_ shadowColor: Any? = nil) -> Self {
|
||||
|
||||
self.layer.shadowOpacity = Float(shadowOpacity)
|
||||
self.layer.shadowRadius = shadowRadius
|
||||
self.layer.shadowOffset = CGSize(width: shadowOffsetX, height: shadowOffsetY)
|
||||
if let color = Color(shadowColor) {
|
||||
self.layer.shadowColor = color.cgColor
|
||||
}
|
||||
return self
|
||||
}
|
||||
|
||||
@ -174,7 +181,7 @@ public extension UIView {
|
||||
/**
|
||||
* Add multiply subviews at the same time.
|
||||
* Usages:
|
||||
.addSubview(view1, view2, view3)
|
||||
.addSubviews(view1, view2, view3)
|
||||
*/
|
||||
@discardableResult public func addSubviews(_ children: Any...) -> Self {
|
||||
func addChildren(_ children: Array<Any>) {
|
||||
@ -229,10 +236,10 @@ public extension UIView {
|
||||
.pin(.xywh(20, 20, 100, 100)) //add left, top, width and height constraints
|
||||
|
||||
.pin(.maxX(-20)) //add right constraint
|
||||
.pin(.maxX(-20)) //add right margin constraint
|
||||
.pin(.maxX("-20")) //add right margin constraint
|
||||
.pin(.maxY(-20)) //add bottom constraint
|
||||
.pin(.maxY(-20)) //add bottom margin constraint
|
||||
.pin(.maxXY(-20, -20)) //add right and bottom constraints
|
||||
.pin(.maxY("-20")) //add bottom margin constraint
|
||||
.pin(.maxXY("-20", "-20")) //add right and bottom constraints
|
||||
|
||||
.pin(.centerX(0)) //add centerX constriant
|
||||
.pin(.centerY(0)) //add centerY constraint
|
||||
|
@ -229,7 +229,7 @@ func cpk_limitTextInput(_ textInput: UITextInput, maxLength: Int) -> Bool {
|
||||
if maxLength > 0, let view = textInput as? UIView {
|
||||
if let text = view.value(forKey: "text") as? String {
|
||||
|
||||
if text.characters.count > maxLength {
|
||||
if text.cpk_length() > maxLength {
|
||||
let newText = text.subTo(maxLength)
|
||||
var needResetCursorPosition = false
|
||||
|
||||
@ -585,6 +585,14 @@ public extension NSObject {
|
||||
|
||||
|
||||
extension String {
|
||||
func cpk_length() -> NSInteger {
|
||||
#if swift(>=3.2)
|
||||
return self.count
|
||||
#else
|
||||
return self.characters.count
|
||||
#endif
|
||||
}
|
||||
|
||||
func cpk_substring(with range: Range<String.Index>) -> String {
|
||||
#if swift(>=4.0)
|
||||
return String(self[range])
|
||||
@ -3105,7 +3113,8 @@ extension UILabel {
|
||||
override public func shadow(_ shadowOpacity: CGFloat,
|
||||
_ shadowRadius: CGFloat = 3,
|
||||
_ shadowOffsetX: CGFloat = 0,
|
||||
_ shadowOffsetY: CGFloat = 3) -> Self {
|
||||
_ shadowOffsetY: CGFloat = 3,
|
||||
_ shadowColor: Any? = nil) -> Self {
|
||||
|
||||
super.shadow(shadowOpacity, shadowRadius, shadowOffsetX, shadowOffsetY)
|
||||
return self
|
||||
@ -3194,7 +3203,8 @@ extension UIImageView {
|
||||
override public func shadow(_ shadowOpacity: CGFloat,
|
||||
_ shadowRadius: CGFloat = 3,
|
||||
_ shadowOffsetX: CGFloat = 0,
|
||||
_ shadowOffsetY: CGFloat = 3) -> Self {
|
||||
_ shadowOffsetY: CGFloat = 3,
|
||||
_ shadowColor: Any? = nil) -> Self {
|
||||
|
||||
super.shadow(shadowOpacity, shadowRadius, shadowOffsetX, shadowOffsetY)
|
||||
return self
|
||||
@ -3277,7 +3287,8 @@ extension UIButton {
|
||||
override public func shadow(_ shadowOpacity: CGFloat,
|
||||
_ shadowRadius: CGFloat = 3,
|
||||
_ shadowOffsetX: CGFloat = 0,
|
||||
_ shadowOffsetY: CGFloat = 3) -> Self {
|
||||
_ shadowOffsetY: CGFloat = 3,
|
||||
_ shadowColor: Any? = nil) -> Self {
|
||||
|
||||
super.shadow(shadowOpacity, shadowRadius, shadowOffsetX, shadowOffsetY)
|
||||
return self
|
||||
@ -3366,7 +3377,8 @@ extension UITextField {
|
||||
override public func shadow(_ shadowOpacity: CGFloat,
|
||||
_ shadowRadius: CGFloat = 3,
|
||||
_ shadowOffsetX: CGFloat = 0,
|
||||
_ shadowOffsetY: CGFloat = 3) -> Self {
|
||||
_ shadowOffsetY: CGFloat = 3,
|
||||
_ shadowColor: Any? = nil) -> Self {
|
||||
|
||||
super.shadow(shadowOpacity, shadowRadius, shadowOffsetX, shadowOffsetY)
|
||||
return self
|
||||
@ -3455,7 +3467,8 @@ extension UITextView {
|
||||
override public func shadow(_ shadowOpacity: CGFloat,
|
||||
_ shadowRadius: CGFloat = 3,
|
||||
_ shadowOffsetX: CGFloat = 0,
|
||||
_ shadowOffsetY: CGFloat = 3) -> Self {
|
||||
_ shadowOffsetY: CGFloat = 3,
|
||||
_ shadowColor: Any? = nil) -> Self {
|
||||
|
||||
super.shadow(shadowOpacity, shadowRadius, shadowOffsetX, shadowOffsetY)
|
||||
return self
|
||||
@ -3544,7 +3557,8 @@ extension CPKStackView {
|
||||
override public func shadow(_ shadowOpacity: CGFloat,
|
||||
_ shadowRadius: CGFloat = 3,
|
||||
_ shadowOffsetX: CGFloat = 0,
|
||||
_ shadowOffsetY: CGFloat = 3) -> Self {
|
||||
_ shadowOffsetY: CGFloat = 3,
|
||||
_ shadowColor: Any? = nil) -> Self {
|
||||
|
||||
super.shadow(shadowOpacity, shadowRadius, shadowOffsetX, shadowOffsetY)
|
||||
return self
|
||||
@ -3631,7 +3645,8 @@ extension StaticTableView {
|
||||
override public func shadow(_ shadowOpacity: CGFloat,
|
||||
_ shadowRadius: CGFloat = 3,
|
||||
_ shadowOffsetX: CGFloat = 0,
|
||||
_ shadowOffsetY: CGFloat = 3) -> Self {
|
||||
_ shadowOffsetY: CGFloat = 3,
|
||||
_ shadowColor: Any? = nil) -> Self {
|
||||
|
||||
super.shadow(shadowOpacity, shadowRadius, shadowOffsetX, shadowOffsetY)
|
||||
return self
|
||||
|
Loading…
Reference in New Issue
Block a user