-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from kazuhiro4949/feature/attachment
Utilize NSTextAttachment
- Loading branch information
Showing
9 changed files
with
96 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,3 +46,4 @@ public extension String { | |
return attributer.range(range) | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// UIImage+StringStylizer.swift | ||
// StringStylizer | ||
// | ||
// Created by kahayash on 2018/03/21. | ||
// Copyright © 2018年 Kazuhiro Hayashi. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
public extension UIImage { | ||
|
||
/// Instantiate NSTextAttachment from the uiimage object. | ||
/// | ||
/// - Parameter size: attachmented image size | ||
/// - Returns: NSTextAttachment | ||
public func textAttachemnt(with size: CGSize) -> NSTextAttachment { | ||
let textAttachemnt = NSTextAttachment() | ||
textAttachemnt.image = self | ||
textAttachemnt.bounds = CGRect(origin: .zero, size: size) | ||
return textAttachemnt | ||
} | ||
|
||
|
||
/// Instantiate NSTextAttachment from the uiimage object. | ||
/// | ||
/// - Parameters: | ||
/// - width: attachmented image width | ||
/// - height: attachmented image height | ||
/// - Returns: NSTextAttachment | ||
public func textAttachemnt(_ width: CGFloat, _ height: CGFloat) -> NSTextAttachment { | ||
let size = CGSize(width: width, height: height) | ||
return textAttachemnt(with: size) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+16.4 KB
...cassets/Attachment.imageset/18425372_1329221433799446_4389587629419729958_n.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions
21
iOS Sample/iOS Sample/Assets.xcassets/Attachment.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "18425372_1329221433799446_4389587629419729958_n.jpg", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters