Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion RxScreenProtectKitTests/RxScreenProtectKitTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,17 @@ final class RxScreenProtectKitTests: XCTestCase {
}

func testSPLabel() {
let changeTextExpectation: XCTestExpectation? = self.expectation(description: "Change Text")
let label = SPLabel()
label.layoutSubviews()
XCTAssertEqual(label.text, nil)
label.text = "original"
label.protectText = "protect"
XCTAssertEqual(label.text, "original")
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
XCTAssertEqual(label.text, "original")
changeTextExpectation?.fulfill()
}
self.waitForExpectations(timeout: 1, handler: nil)
}

func testPixelBoxSize() {
Expand Down
10 changes: 6 additions & 4 deletions Source/SPLabel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,18 @@ public final class SPLabel: UILabel {
private var original: String?
/// Specify the character string to be replaced during recording.
/// If nothing is specified, `nil` is assigned to `text` when a recording is detected.
public var protectText: String?
public var protectText: String? {
didSet {
load.onNext(())
}
}
/// The current text that is displayed by the label.
/// Please note that when recording, a different string will be returned from the original string.
override public var text: String? {
set {
super.text = newValue
original = newValue
if newValue != nil {
load.onNext(())
}
load.onNext(())
}
get {
return super.text
Expand Down