Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
Merge branch 'deploy/1.7.0' into productive
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeehut committed Apr 7, 2018
2 parents f34f5d9 + f4a622c commit 2e5469e
Show file tree
Hide file tree
Showing 18 changed files with 289 additions and 14 deletions.
2 changes: 1 addition & 1 deletion HandyUIKit.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "HandyUIKit"
s.version = "1.6.0"
s.version = "1.7.0"
s.summary = "Handy UI features that should have been part of UIKit in the first place."

s.description = <<-DESC
Expand Down
40 changes: 35 additions & 5 deletions HandyUIKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
objects = {

/* Begin PBXBuildFile section */
2E1DABDE20790C1700627CC2 /* UIImageExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2E1DABDD20790C1700627CC2 /* UIImageExtensionTests.swift */; };
2E1DABDF20790C1700627CC2 /* UIImageExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2E1DABDD20790C1700627CC2 /* UIImageExtensionTests.swift */; };
2E1DABE520790F5900627CC2 /* Media.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2E1DABE420790F5900627CC2 /* Media.xcassets */; };
2E1DABE620790F5900627CC2 /* Media.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2E1DABE420790F5900627CC2 /* Media.xcassets */; };
2E71660A207904A200135F39 /* UIImageExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2E716609207904A200135F39 /* UIImageExtension.swift */; };
2E71660B207904A200135F39 /* UIImageExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2E716609207904A200135F39 /* UIImageExtension.swift */; };
A11830F31E5996FD00CBE087 /* StringExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = A11830F21E5996FD00CBE087 /* StringExtension.swift */; };
A11830F41E5996FD00CBE087 /* StringExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = A11830F21E5996FD00CBE087 /* StringExtension.swift */; };
A11830F61E599BF600CBE087 /* StringExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A11830F51E599BF600CBE087 /* StringExtensionTests.swift */; };
Expand Down Expand Up @@ -47,6 +53,9 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
2E1DABDD20790C1700627CC2 /* UIImageExtensionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIImageExtensionTests.swift; sourceTree = "<group>"; };
2E1DABE420790F5900627CC2 /* Media.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Media.xcassets; sourceTree = "<group>"; };
2E716609207904A200135F39 /* UIImageExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIImageExtension.swift; sourceTree = "<group>"; };
A11830F21E5996FD00CBE087 /* StringExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StringExtension.swift; sourceTree = "<group>"; };
A11830F51E599BF600CBE087 /* StringExtensionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StringExtensionTests.swift; sourceTree = "<group>"; };
A14E0ABC1E1F986A00DFC788 /* HandyUIKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = HandyUIKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -104,6 +113,14 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
2E1DABE020790DC300627CC2 /* Assets */ = {
isa = PBXGroup;
children = (
2E1DABE420790F5900627CC2 /* Media.xcassets */,
);
path = Assets;
sourceTree = "<group>";
};
A14E0AB21E1F986A00DFC788 = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -153,6 +170,7 @@
A14E0AF71E1F98E400DFC788 /* Tests */ = {
isa = PBXGroup;
children = (
2E1DABE020790DC300627CC2 /* Assets */,
A14E0AF81E1F98E400DFC788 /* Code */,
A14E0AFA1E1F98E400DFC788 /* Supporting Files */,
);
Expand All @@ -165,6 +183,7 @@
A1F2216D1E3E0B7700419B06 /* CoreExtensionTests.swift */,
A1F2217B1E3E2C5500419B06 /* CoreGraphicsExtensionTests.swift */,
A11830F51E599BF600CBE087 /* StringExtensionTests.swift */,
2E1DABDD20790C1700627CC2 /* UIImageExtensionTests.swift */,
);
path = Code;
sourceTree = "<group>";
Expand All @@ -180,12 +199,13 @@
A14E0B0C1E1F9B3100DFC788 /* Extensions */ = {
isa = PBXGroup;
children = (
A1F2217E1E3E777600419B06 /* Helpers */,
A14E0B0E1E1F9B3100DFC788 /* UIViewExtension.swift */,
A1F221671E3E07DD00419B06 /* UIColorExtension.swift */,
A1F2216A1E3E08AE00419B06 /* CoreGraphicsExtension.swift */,
A11830F21E5996FD00CBE087 /* StringExtension.swift */,
A1F2217E1E3E777600419B06 /* Helpers */,
A1D4453B1E59C9370014A250 /* NSAttributedStringExtension.swift */,
A11830F21E5996FD00CBE087 /* StringExtension.swift */,
A1F221671E3E07DD00419B06 /* UIColorExtension.swift */,
2E716609207904A200135F39 /* UIImageExtension.swift */,
A14E0B0E1E1F9B3100DFC788 /* UIViewExtension.swift */,
);
path = Extensions;
sourceTree = "<group>";
Expand Down Expand Up @@ -312,7 +332,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0820;
LastUpgradeCheck = 0900;
LastUpgradeCheck = 0930;
ORGANIZATIONNAME = Flinesoft;
TargetAttributes = {
A14E0ABB1E1F986A00DFC788 = {
Expand Down Expand Up @@ -371,6 +391,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
2E1DABE520790F5900627CC2 /* Media.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -385,6 +406,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
2E1DABE620790F5900627CC2 /* Media.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -428,6 +450,7 @@
files = (
A1F221801E3E778F00419B06 /* ColorSpaces.swift in Sources */,
A1F221681E3E07DD00419B06 /* UIColorExtension.swift in Sources */,
2E71660A207904A200135F39 /* UIImageExtension.swift in Sources */,
A11830F31E5996FD00CBE087 /* StringExtension.swift in Sources */,
A1D4453C1E59C9370014A250 /* NSAttributedStringExtension.swift in Sources */,
A1F2216B1E3E08AF00419B06 /* CoreGraphicsExtension.swift in Sources */,
Expand All @@ -442,6 +465,7 @@
A1F2217C1E3E2C5500419B06 /* CoreGraphicsExtensionTests.swift in Sources */,
A1F221701E3E0B8400419B06 /* CoreExtensionTests.swift in Sources */,
A11830F61E599BF600CBE087 /* StringExtensionTests.swift in Sources */,
2E1DABDE20790C1700627CC2 /* UIImageExtensionTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -451,6 +475,7 @@
files = (
A1F221811E3E778F00419B06 /* ColorSpaces.swift in Sources */,
A1F221691E3E07DD00419B06 /* UIColorExtension.swift in Sources */,
2E71660B207904A200135F39 /* UIImageExtension.swift in Sources */,
A11830F41E5996FD00CBE087 /* StringExtension.swift in Sources */,
A1D4453D1E59C9370014A250 /* NSAttributedStringExtension.swift in Sources */,
A1F2216C1E3E08AF00419B06 /* CoreGraphicsExtension.swift in Sources */,
Expand All @@ -465,6 +490,7 @@
A1F2217D1E3E2C5500419B06 /* CoreGraphicsExtensionTests.swift in Sources */,
A1F221711E3E0B8500419B06 /* CoreExtensionTests.swift in Sources */,
A11830F71E599BF600CBE087 /* StringExtensionTests.swift in Sources */,
2E1DABDF20790C1700627CC2 /* UIImageExtensionTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -497,13 +523,15 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
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_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand Down Expand Up @@ -557,13 +585,15 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
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_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?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>classNames</key>
<dict>
<key>UIImageExtensionTests</key>
<dict>
<key>testPerformanceToGrayscale()</key>
<dict>
<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
<dict>
<key>baselineAverage</key>
<real>0.49576</real>
<key>baselineIntegrationDisplayName</key>
<string>Local Baseline</string>
</dict>
</dict>
</dict>
</dict>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?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>runDestinationsByUUID</key>
<dict>
<key>C3ECA4DA-1F82-4ABC-A31B-85A51942BB0D</key>
<dict>
<key>localComputer</key>
<dict>
<key>busSpeedInMHz</key>
<integer>100</integer>
<key>cpuCount</key>
<integer>1</integer>
<key>cpuKind</key>
<string>Intel Core i7</string>
<key>cpuSpeedInMHz</key>
<integer>2900</integer>
<key>logicalCPUCoresPerPackage</key>
<integer>8</integer>
<key>modelCode</key>
<string>MacBookPro14,3</string>
<key>physicalCPUCoresPerPackage</key>
<integer>4</integer>
<key>platformIdentifier</key>
<string>com.apple.platform.macosx</string>
</dict>
<key>targetArchitecture</key>
<string>x86_64</string>
<key>targetDevice</key>
<dict>
<key>modelCode</key>
<string>iPhone10,5</string>
<key>platformIdentifier</key>
<string>com.apple.platform.iphonesimulator</string>
</dict>
</dict>
</dict>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
LastUpgradeVersion = "0930"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
LastUpgradeVersion = "0930"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
8 changes: 8 additions & 0 deletions HandyUIKit.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?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>
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ alt="Build Status">
alt="codebeat badge">
</a>
<a href="https://github.com/Flinesoft/HandyUIKit/releases">
<img src="https://img.shields.io/badge/Version-1.6.0-blue.svg"
alt="Version: 1.6.0">
<img src="https://img.shields.io/badge/Version-1.7.0-blue.svg"
alt="Version: 1.7.0">
</a>
<img src="https://img.shields.io/badge/Swift-4.0-FFAC45.svg"
alt="Swift: 4.0">
<img src="https://img.shields.io/badge/Swift-4.1-FFAC45.svg"
alt="Swift: 4.1">
<img src="https://img.shields.io/badge/Platforms-iOS%20%7C%20tvOS-FF69B4.svg"
alt="Platforms: iOS | tvOS">
<a href="https://github.com/Flinesoft/HandyUIKit/blob/stable/LICENSE.md">
Expand Down Expand Up @@ -91,6 +91,7 @@ Open the Playground from within the `.xcworkspace` in order for it to work.
- [UIView](#uiviewextension)
- [CoreGraphics](#coregraphicsextensions)
- [StringExtension](#stringextension)
- [UIImageExtension](#uiimageextension)

---

Expand Down Expand Up @@ -278,7 +279,14 @@ Result: CO<sub>2</sub>
```
Result: <sub>20</sub>Ca<sup>1,0</sup>

### UIImageExtension
#### .toGrayscale()
Creates a grayscale version of the image.

``` Swift
let image = UIImage(named: "someImage")!
let grayscaleImage = image.toGrayscale()
```

## Contributing

Expand Down
2 changes: 1 addition & 1 deletion Sources/Code/Extensions/UIColorExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ extension UIColor {
/// - attribute: The attribute to change.
/// - to: The new value to be set for the attribute.
/// - Returns: The resulting new `UIColor` with the specified change applied.
public func change(_ attribute: ChangeableAttribute, to newValue: CGFloat) -> UIColor { // swiftlint:disable:this cyclomatic_complexity
public func change(_ attribute: ChangeableAttribute, to newValue: CGFloat) -> UIColor {
switch attribute {
case .red, .green, .blue:
return newRgbaColor(attribute, newValue)
Expand Down
35 changes: 35 additions & 0 deletions Sources/Code/Extensions/UIImageExtension.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// UIImageExtension.swift
// HandyUIKit
//
// Created by Cihat Gündüz on 07.04.18.
// Copyright © 2018 Flinesoft. All rights reserved.
//

import UIKit

extension UIImage {
/// Creates a grayscale version of the image.
///
/// - Returns: The grayscale image.
public func toGrayscale() -> UIImage? {
let imageRect = CGRect(size: size)
let colorSpace = CGColorSpaceCreateDeviceGray()
let bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.none.rawValue)
let contextOptional = CGContext(
data: nil,
width: Int(size.width),
height: Int(size.height),
bitsPerComponent: 8,
bytesPerRow: 0,
space: colorSpace,
bitmapInfo: bitmapInfo.rawValue
)

guard let context = contextOptional else { return nil }
context.draw(cgImage!, in: imageRect)

guard let grayscaleCgImage = context.makeImage() else { return nil }
return UIImage(cgImage: grayscaleCgImage)
}
}
Loading

0 comments on commit 2e5469e

Please sign in to comment.