mirror of
https://github.com/MessageKit/MessageKit.git
synced 2026-02-06 19:03:19 +00:00
+1
-1
@@ -1 +1 @@
|
||||
3.0
|
||||
4.0
|
||||
|
||||
@@ -7,6 +7,10 @@ The changelog for `MessageKit`. Also see the [releases](https://github.com/Messa
|
||||
## Upcoming release
|
||||
----------------
|
||||
|
||||
## [Prerelease] 0.8.2
|
||||
### Added
|
||||
- Support for Swift 4
|
||||
|
||||
## [Prerelease] 0.8.1
|
||||
### Added
|
||||
- Support for Swift 3.2 and Xcode 9
|
||||
|
||||
@@ -595,7 +595,7 @@
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_VERSION = 4.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = Debug;
|
||||
@@ -642,7 +642,7 @@
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_VERSION = 4.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
@@ -659,7 +659,7 @@
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.messagekit.ChatExample;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_VERSION = 4.0;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
@@ -675,7 +675,7 @@
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.messagekit.ChatExample;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_VERSION = 4.0;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
@@ -688,7 +688,7 @@
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.hexedbits.ChatExampleTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_VERSION = 4.0;
|
||||
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ChatExample.app/ChatExample";
|
||||
};
|
||||
name = Debug;
|
||||
@@ -703,7 +703,7 @@
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.hexedbits.ChatExampleTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_VERSION = 4.0;
|
||||
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ChatExample.app/ChatExample";
|
||||
};
|
||||
name = Release;
|
||||
@@ -716,7 +716,7 @@
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.hexedbits.ChatExampleUITests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_VERSION = 4.0;
|
||||
TEST_TARGET_NAME = ChatExample;
|
||||
};
|
||||
name = Debug;
|
||||
@@ -730,7 +730,7 @@
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.hexedbits.ChatExampleUITests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_VERSION = 4.0;
|
||||
TEST_TARGET_NAME = ChatExample;
|
||||
};
|
||||
name = Release;
|
||||
|
||||
@@ -45,7 +45,7 @@ class ConversationViewController: MessagesViewController {
|
||||
action: #selector(handleKeyboardButton))
|
||||
}
|
||||
|
||||
func handleKeyboardButton() {
|
||||
@objc func handleKeyboardButton() {
|
||||
|
||||
let actionSheetController = UIAlertController(title: "Change Keyboard Style", message: nil, preferredStyle: .actionSheet)
|
||||
let actions = [
|
||||
@@ -198,14 +198,14 @@ extension ConversationViewController: MessagesDataSource {
|
||||
|
||||
func cellTopLabelAttributedText(for message: MessageType, at indexPath: IndexPath) -> NSAttributedString? {
|
||||
let name = message.sender.displayName
|
||||
return NSAttributedString(string: name, attributes: [NSFontAttributeName: UIFont.preferredFont(forTextStyle: .caption1)])
|
||||
return NSAttributedString(string: name, attributes: [NSAttributedStringKey.font: UIFont.preferredFont(forTextStyle: .caption1)])
|
||||
}
|
||||
|
||||
func cellBottomLabelAttributedText(for message: MessageType, at indexPath: IndexPath) -> NSAttributedString? {
|
||||
let formatter = DateFormatter()
|
||||
formatter.dateStyle = .medium
|
||||
let dateString = formatter.string(from: message.sentDate)
|
||||
return NSAttributedString(string: dateString, attributes: [NSFontAttributeName: UIFont.preferredFont(forTextStyle: .caption2)])
|
||||
return NSAttributedString(string: dateString, attributes: [NSAttributedStringKey.font: UIFont.preferredFont(forTextStyle: .caption2)])
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -46,11 +46,11 @@ struct SampleData {
|
||||
let msg9Text = NSString(string: msg9String)
|
||||
let msg9AttributedText = NSMutableAttributedString(string: String(msg9Text))
|
||||
|
||||
msg9AttributedText.addAttribute(NSFontAttributeName, value: UIFont.preferredFont(forTextStyle: .body), range: NSRange(location: 0, length: msg9Text.length))
|
||||
msg9AttributedText.addAttributes([NSFontAttributeName: UIFont.monospacedDigitSystemFont(ofSize: UIFont.systemFontSize, weight: UIFontWeightBold)], range: msg9Text.range(of: ".attributedText()"))
|
||||
msg9AttributedText.addAttributes([NSFontAttributeName: UIFont.boldSystemFont(ofSize: UIFont.systemFontSize)], range: msg9Text.range(of: "bold"))
|
||||
msg9AttributedText.addAttributes([NSFontAttributeName: UIFont.italicSystemFont(ofSize: UIFont.systemFontSize)], range: msg9Text.range(of: "italic"))
|
||||
msg9AttributedText.addAttributes([NSForegroundColorAttributeName: UIColor.red], range: msg9Text.range(of: "colored"))
|
||||
msg9AttributedText.addAttribute(NSAttributedStringKey.font, value: UIFont.preferredFont(forTextStyle: .body), range: NSRange(location: 0, length: msg9Text.length))
|
||||
msg9AttributedText.addAttributes([NSAttributedStringKey.font: UIFont.monospacedDigitSystemFont(ofSize: UIFont.systemFontSize, weight: UIFont.Weight.bold)], range: msg9Text.range(of: ".attributedText()"))
|
||||
msg9AttributedText.addAttributes([NSAttributedStringKey.font: UIFont.boldSystemFont(ofSize: UIFont.systemFontSize)], range: msg9Text.range(of: "bold"))
|
||||
msg9AttributedText.addAttributes([NSAttributedStringKey.font: UIFont.italicSystemFont(ofSize: UIFont.systemFontSize)], range: msg9Text.range(of: "italic"))
|
||||
msg9AttributedText.addAttributes([NSAttributedStringKey.foregroundColor: UIColor.red], range: msg9Text.range(of: "colored"))
|
||||
|
||||
var msg9 = MockMessage(attributedText: msg9AttributedText, sender: Jobs, messageId: UUID().uuidString)
|
||||
var msg10 = MockMessage(text: "1-800-555-0000", sender: Dan, messageId: UUID().uuidString)
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'MessageKit'
|
||||
s.version = '0.8.1'
|
||||
s.version = '0.8.2'
|
||||
s.license = { :type => "MIT", :file => "LICENSE.md" }
|
||||
|
||||
s.summary = 'An elegant messages UI library for iOS.'
|
||||
@@ -12,7 +12,7 @@ Pod::Spec.new do |s|
|
||||
s.source_files = 'Sources/*.swift'
|
||||
|
||||
s.pod_target_xcconfig = {
|
||||
"SWIFT_VERSION" => "3.0",
|
||||
"SWIFT_VERSION" => "4.0",
|
||||
}
|
||||
|
||||
s.ios.deployment_target = '9.0'
|
||||
|
||||
@@ -554,7 +554,7 @@
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_VERSION = 4.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
@@ -604,7 +604,7 @@
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_VERSION = 4.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
@@ -629,7 +629,7 @@
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_VERSION = 4.0;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
@@ -650,7 +650,7 @@
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_VERSION = 4.0;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
|
||||
@@ -102,7 +102,7 @@ open class AvatarView: UIView {
|
||||
|
||||
let textStyle = NSMutableParagraphStyle()
|
||||
textStyle.alignment = .center
|
||||
let textFontAttributes: [String: Any] = [NSFontAttributeName: font, NSForegroundColorAttributeName: placeholderTextColor, NSParagraphStyleAttributeName: textStyle]
|
||||
let textFontAttributes: [NSAttributedStringKey: Any] = [NSAttributedStringKey.font: font, NSAttributedStringKey.foregroundColor: placeholderTextColor, NSAttributedStringKey.paragraphStyle: textStyle]
|
||||
|
||||
let textTextHeight: CGFloat = initals.boundingRect(with: CGSize(width: textRect.width, height: CGFloat.infinity), options: .usesLineFragmentOrigin, attributes: textFontAttributes, context: nil).height
|
||||
context.saveGState()
|
||||
|
||||
@@ -43,11 +43,11 @@ open class InputBarButtonItem: UIButton {
|
||||
didSet {
|
||||
switch spacing {
|
||||
case .flexible:
|
||||
setContentHuggingPriority(1, for: .horizontal)
|
||||
setContentHuggingPriority(UILayoutPriority(rawValue: 1), for: .horizontal)
|
||||
case .fixed:
|
||||
setContentHuggingPriority(1000, for: .horizontal)
|
||||
setContentHuggingPriority(UILayoutPriority(rawValue: 1000), for: .horizontal)
|
||||
case .none:
|
||||
setContentHuggingPriority(500, for: .horizontal)
|
||||
setContentHuggingPriority(UILayoutPriority(rawValue: 500), for: .horizontal)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -144,8 +144,8 @@ open class InputBarButtonItem: UIButton {
|
||||
contentVerticalAlignment = .center
|
||||
contentHorizontalAlignment = .center
|
||||
imageView?.contentMode = .scaleAspectFit
|
||||
setContentHuggingPriority(500, for: .horizontal)
|
||||
setContentHuggingPriority(500, for: .vertical)
|
||||
setContentHuggingPriority(UILayoutPriority(rawValue: 500), for: .horizontal)
|
||||
setContentHuggingPriority(UILayoutPriority(rawValue: 500), for: .vertical)
|
||||
setTitleColor(UIColor(red: 0, green: 122/255, blue: 1, alpha: 1), for: .normal)
|
||||
setTitleColor(UIColor(red: 0, green: 122/255, blue: 1, alpha: 0.3), for: .highlighted)
|
||||
setTitleColor(.lightGray, for: .disabled)
|
||||
@@ -234,7 +234,7 @@ open class InputBarButtonItem: UIButton {
|
||||
onKeyboardEditingBeginsAction?(self)
|
||||
}
|
||||
|
||||
public func touchUpInsideAction() {
|
||||
@objc public func touchUpInsideAction() {
|
||||
onTouchUpInsideAction?(self)
|
||||
}
|
||||
|
||||
|
||||
@@ -164,19 +164,19 @@ open class MessageCollectionViewCell<ContentView: UIView>: UICollectionViewCell
|
||||
|
||||
// MARK: - Delegate Methods
|
||||
|
||||
func didTapAvatar() {
|
||||
@objc func didTapAvatar() {
|
||||
delegate?.didTapAvatar(in: self)
|
||||
}
|
||||
|
||||
func didTapMessage() {
|
||||
@objc func didTapMessage() {
|
||||
delegate?.didTapMessage(in: self)
|
||||
}
|
||||
|
||||
func didTapTopLabel() {
|
||||
@objc func didTapTopLabel() {
|
||||
delegate?.didTapTopLabel(in: self)
|
||||
}
|
||||
|
||||
func didTapBottomLabel() {
|
||||
@objc func didTapBottomLabel() {
|
||||
delegate?.didTapBottomLabel(in: self)
|
||||
}
|
||||
|
||||
|
||||
@@ -419,11 +419,11 @@ open class MessageInputBar: UIView {
|
||||
|
||||
// MARK: - Notifications/Hooks
|
||||
|
||||
open func orientationDidChange() {
|
||||
@objc open func orientationDidChange() {
|
||||
invalidateIntrinsicContentSize()
|
||||
}
|
||||
|
||||
open func textViewDidChange() {
|
||||
@objc open func textViewDidChange() {
|
||||
let trimmedText = inputTextView.text.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
|
||||
sendButton.isEnabled = !trimmedText.isEmpty
|
||||
@@ -435,11 +435,11 @@ open class MessageInputBar: UIView {
|
||||
invalidateIntrinsicContentSize()
|
||||
}
|
||||
|
||||
open func textViewDidBeginEditing() {
|
||||
@objc open func textViewDidBeginEditing() {
|
||||
self.items.forEach { $0.keyboardEditingBeginsAction() }
|
||||
}
|
||||
|
||||
open func textViewDidEndEditing() {
|
||||
@objc open func textViewDidEndEditing() {
|
||||
self.items.forEach { $0.keyboardEditingEndsAction() }
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ open class MessageKitDateFormatter {
|
||||
return formatter.string(from: date)
|
||||
}
|
||||
|
||||
public func attributedString(from date: Date, with attributes: [String: Any]) -> NSAttributedString {
|
||||
public func attributedString(from date: Date, with attributes: [NSAttributedStringKey: Any]) -> NSAttributedString {
|
||||
let dateString = string(from: date)
|
||||
return NSAttributedString(string: dateString, attributes: attributes)
|
||||
}
|
||||
|
||||
+16
-16
@@ -119,28 +119,28 @@ open class MessageLabel: UILabel, UIGestureRecognizerDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
open var addressAttributes: [String: Any] = [:] {
|
||||
open var addressAttributes: [NSAttributedStringKey: Any] = [:] {
|
||||
didSet {
|
||||
updateAttributes(for: .address)
|
||||
setNeedsDisplay()
|
||||
}
|
||||
}
|
||||
|
||||
open var dateAttributes: [String: Any] = [:] {
|
||||
open var dateAttributes: [NSAttributedStringKey: Any] = [:] {
|
||||
didSet {
|
||||
updateAttributes(for: .date)
|
||||
setNeedsDisplay()
|
||||
}
|
||||
}
|
||||
|
||||
open var phoneNumberAttributes: [String: Any] = [:] {
|
||||
open var phoneNumberAttributes: [NSAttributedStringKey: Any] = [:] {
|
||||
didSet {
|
||||
updateAttributes(for: .phoneNumber)
|
||||
setNeedsDisplay()
|
||||
}
|
||||
}
|
||||
|
||||
open var urlAttributes: [String: Any] = [:] {
|
||||
open var urlAttributes: [NSAttributedStringKey: Any] = [:] {
|
||||
didSet {
|
||||
updateAttributes(for: .url)
|
||||
setNeedsDisplay()
|
||||
@@ -156,10 +156,10 @@ open class MessageLabel: UILabel, UIGestureRecognizerDelegate {
|
||||
self.numberOfLines = 0
|
||||
self.lineBreakMode = .byWordWrapping
|
||||
|
||||
let defaultAttributes: [String: Any] = [
|
||||
NSForegroundColorAttributeName: self.textColor,
|
||||
NSUnderlineStyleAttributeName: NSUnderlineStyle.styleSingle.rawValue,
|
||||
NSUnderlineColorAttributeName: self.textColor
|
||||
let defaultAttributes: [NSAttributedStringKey: Any] = [
|
||||
NSAttributedStringKey.foregroundColor: self.textColor,
|
||||
NSAttributedStringKey.underlineStyle: NSUnderlineStyle.styleSingle.rawValue,
|
||||
NSAttributedStringKey.underlineColor: self.textColor
|
||||
]
|
||||
|
||||
self.addressAttributes = defaultAttributes
|
||||
@@ -210,7 +210,7 @@ open class MessageLabel: UILabel, UIGestureRecognizerDelegate {
|
||||
guard let index = stringIndex(at: touchLocation) else { return true }
|
||||
for (_, ranges) in rangesForDetectors {
|
||||
for (nsRange, _) in ranges {
|
||||
guard let range = nsRange.toRange() else { return true }
|
||||
guard let range = Range(nsRange) else { return true }
|
||||
if range.contains(index) { return false }
|
||||
}
|
||||
}
|
||||
@@ -219,7 +219,7 @@ open class MessageLabel: UILabel, UIGestureRecognizerDelegate {
|
||||
guard let index = stringIndex(at: touchLocation) else { return false }
|
||||
for (_, ranges) in rangesForDetectors {
|
||||
for (nsRange, _) in ranges {
|
||||
guard let range = nsRange.toRange() else { return false }
|
||||
guard let range = Range(nsRange) else { return false }
|
||||
if range.contains(index) { return true }
|
||||
}
|
||||
}
|
||||
@@ -266,11 +266,11 @@ open class MessageLabel: UILabel, UIGestureRecognizerDelegate {
|
||||
let mutableAttributedString = NSMutableAttributedString(attributedString: text)
|
||||
var textRange = NSRange(location: 0, length: 0)
|
||||
|
||||
let paragraphStyle = text.attribute(NSParagraphStyleAttributeName, at: 0, effectiveRange: &textRange) as? NSMutableParagraphStyle ?? NSMutableParagraphStyle()
|
||||
let paragraphStyle = text.attribute(NSAttributedStringKey.paragraphStyle, at: 0, effectiveRange: &textRange) as? NSMutableParagraphStyle ?? NSMutableParagraphStyle()
|
||||
paragraphStyle.lineBreakMode = lineBreakMode
|
||||
paragraphStyle.alignment = textAlignment
|
||||
|
||||
mutableAttributedString.addAttribute(NSParagraphStyleAttributeName, value: paragraphStyle, range: textRange)
|
||||
mutableAttributedString.addAttribute(NSAttributedStringKey.paragraphStyle, value: paragraphStyle, range: textRange)
|
||||
|
||||
return mutableAttributedString
|
||||
|
||||
@@ -304,7 +304,7 @@ open class MessageLabel: UILabel, UIGestureRecognizerDelegate {
|
||||
|
||||
}
|
||||
|
||||
private func detectorAttributes(for detectorType: DetectorType) -> [String: Any] {
|
||||
private func detectorAttributes(for detectorType: DetectorType) -> [NSAttributedStringKey: Any] {
|
||||
|
||||
switch detectorType {
|
||||
case .address:
|
||||
@@ -319,7 +319,7 @@ open class MessageLabel: UILabel, UIGestureRecognizerDelegate {
|
||||
|
||||
}
|
||||
|
||||
private func detectorAttributes(for checkingResultType: NSTextCheckingResult.CheckingType) -> [String: Any] {
|
||||
private func detectorAttributes(for checkingResultType: NSTextCheckingResult.CheckingType) -> [NSAttributedStringKey: Any] {
|
||||
switch checkingResultType {
|
||||
case NSTextCheckingResult.CheckingType.address:
|
||||
return addressAttributes
|
||||
@@ -413,14 +413,14 @@ open class MessageLabel: UILabel, UIGestureRecognizerDelegate {
|
||||
isUserInteractionEnabled = true
|
||||
}
|
||||
|
||||
func handleGesture(_ gesture: UIGestureRecognizer) {
|
||||
@objc func handleGesture(_ gesture: UIGestureRecognizer) {
|
||||
|
||||
let touchLocation = gesture.location(ofTouch: 0, in: self)
|
||||
guard let index = stringIndex(at: touchLocation) else { return }
|
||||
|
||||
for (detectorType, ranges) in rangesForDetectors {
|
||||
for (nsRange, value) in ranges {
|
||||
guard let range = nsRange.toRange() else { return }
|
||||
guard let range = Range(nsRange) else { return }
|
||||
if range.contains(index) {
|
||||
handleGesture(for: detectorType, value: value)
|
||||
}
|
||||
|
||||
@@ -268,7 +268,7 @@ extension MessagesViewController {
|
||||
NotificationCenter.default.removeObserver(self, name: .UIKeyboardWillChangeFrame, object: nil)
|
||||
}
|
||||
|
||||
func handleKeyboardDidChangeState(_ notification: Notification) {
|
||||
@objc func handleKeyboardDidChangeState(_ notification: Notification) {
|
||||
|
||||
guard let keyboardEndFrame = notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? CGRect else { return }
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ extension String {
|
||||
func height(considering width: CGFloat, and font: UIFont) -> CGFloat {
|
||||
|
||||
let constraintBox = CGSize(width: width, height: .greatestFiniteMagnitude)
|
||||
let rect = self.boundingRect(with: constraintBox, options: .usesLineFragmentOrigin, attributes: [NSFontAttributeName: font], context: nil)
|
||||
let rect = self.boundingRect(with: constraintBox, options: .usesLineFragmentOrigin, attributes: [NSAttributedStringKey.font: font], context: nil)
|
||||
return rect.height
|
||||
|
||||
}
|
||||
@@ -37,7 +37,7 @@ extension String {
|
||||
func width(considering height: CGFloat, and font: UIFont) -> CGFloat {
|
||||
|
||||
let constraintBox = CGSize(width: .greatestFiniteMagnitude, height: height)
|
||||
let rect = self.boundingRect(with: constraintBox, options: .usesLineFragmentOrigin, attributes: [NSFontAttributeName: font], context: nil)
|
||||
let rect = self.boundingRect(with: constraintBox, options: .usesLineFragmentOrigin, attributes: [NSAttributedStringKey.font: font], context: nil)
|
||||
return rect.width
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user