MRAttributedTextView is made with UiKit.It allows you to change the font
and color
of substrings and also handle substring click
events.
GeometryReader { proxy in
MRAttributedTextView(text: "We'will send you an One Time Password on this +918141691419",
subStrings: ["One Time Password","+918141691419"],
width: proxy,
onTapItemString: { value in
//handle actions
if value == "+918141691419" {
}
})
}
GeometryReader { proxy in
MRAttributedTextView(text: "We'will send you an One Time Password on this +918141691419",
subStrings: ["One Time Password","+918141691419"],
width: proxy,
textFont: .systemFont(ofSize: 16),
subsStringFont: .systemFont(ofSize: 16, weight: .bold),
subsStringColor: .black,
alignment: .center,
onTapItemString: { value in
//handle actions
})
}
GeometryReader { proxy in
MRAttributedTextView(text: "By signing up you are agree to our Terms & Condition and Privacy Policy",
subStrings: ["Terms & Condition","Privacy Policy"],
width: proxy,
textFont: .systemFont(ofSize: 16),
subsStringFont: .systemFont(ofSize: 16, weight: .bold),
subsStringColor: .systemBlue, alignment: .center,
onTapItemString: { value in
if value == "Privacy Policy" {
//handle action
} else {
}
})
}
Note:- If you want padding, use padding horizontal with the same value as padding modifier.
GeometryReader { proxy in
MRAttributedTextView(text: "By signing up you are agree to our Terms & Condition and Privacy Policy",
subStrings: ["Terms & Condition","Privacy Policy"],
width: proxy,
textFont: .systemFont(ofSize: 16),
subsStringFont: .systemFont(ofSize: 16, weight: .bold),
subsStringColor: .systemBlue,
alignment: .left,
paddingHorizontal: 8, // Mandatory
onTapItemString: { value in
//handle actions
})
.padding(8) //Same as paddingHorizontal value
}
If you have any feedback, please reach out to us at [email protected]
link |
Stars: 7 |
Last commit: 2 years ago |
Initial Release Added by @MaheshRathod4
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics