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
// | |
// ViewController.swift | |
// UITextViewPractices | |
// | |
// Created by yosshi4486 on 2021/10/13. | |
// | |
import UIKit | |
class ViewController: UIViewController { |
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
class ViewController: UIViewController { | |
var leftTextView: UITextView! | |
var rightTextView: UITextView! | |
lazy var textStorage = NSTextStorage(string: """ | |
「ではみなさんは、そういうふうに川だと云いわれたり、乳の流れたあとだと云われたりしていたこのぼんやりと白いものがほんとうは何かご承知ですか。」先生は、黒板に吊つるした大きな黒い星座の図の、上から下へ白くけぶった銀河帯のようなところを指さしながら、みんなに問といをかけました。 | |
カムパネルラが手をあげました。それから四五人手をあげました。ジョバンニも手をあげようとして、急いでそのままやめました。たしかにあれがみんな星だと、いつか雑誌で読んだのでしたが、このごろはジョバンニはまるで毎日教室でもねむく、本を読むひまも読む本もないので、なんだかどんなこともよくわからないという気持ちがするのでした。 | |
ところが先生は早くもそれを見附みつけたのでした。 | |
「ジョバンニさん。あなたはわかっているのでしょう。」 |
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
let string = "🤩" | |
let bounds = CGRect(x: 0, y: 0, width: 30, height: 30) | |
let image = UIGraphicsImageRenderer(size: bounds.size).image { context in | |
let attributes: [NSAttributedString.Key: Any] = [ | |
.font: UIFont.preferredFont(forTextStyle: .body), | |
.foregroundColor: UIColor.label | |
] |
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
// | |
// ReviewRequestManager.swift | |
// | |
// Created by yosshi4486 on 2021/07/22. | |
// | |
import StoreKit | |
/// The global variable to get current app version. | |
/// |
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
extension Array where Element == List { | |
func canMove(into otherContainer: List) -> Bool { | |
return allSatisfy({ $0.canMove(into: otherContainer) }) | |
} | |
} |
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
struct Feature { | |
var title: String | |
} | |
extension Feature: CustomStringConvertible { | |
var description: String { | |
return title | |
} |
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
private func accessibilityLabelForCreatedDateLabel(from date: Date) -> String { | |
return String(format: NSLocalizedString("Created: %@", comment: "An accessibility label of created date."), self.accessibilityLabel(for: date) ?? "") | |
} | |
private func accessibilityLabelForUpdatedDateLabel(from date: Date) -> String { | |
return String(format: NSLocalizedString("Updated: %@", comment: "An accessibility label of updated date."), self.accessibilityLabel(for: date) ?? "") | |
} | |
private func accessibilityLabel(for date: Date) -> String? { | |
let timeComponentFormatter = DateComponentsFormatter() |
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
// 画像のサイズよりもタップ領域を広げたいので、contentViewを別途設けており、それのアクセシビリティ要素にしたい | |
taskContentView.isAccessibilityElement = true | |
taskContentView.accessibilityLabel = NSLocalizedString("Task Status", comment: "") | |
taskContentView.accessibilityCustomActions = [ | |
UIAccessibilityCustomAction(name: NSLocalizedString("Toggle task status", comment: ""), actionHandler: { [weak self] (action) -> Bool in | |
self?.toggleDone(action) | |
return true | |
}) | |
] |