-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added RichTextViewController with RichTextView and ToolBar. #7
base: feature/rich_text
Are you sure you want to change the base?
added RichTextViewController with RichTextView and ToolBar. #7
Conversation
added text formatting using toolbar buttons and text formatting in a specific range
|
||
import UIKit | ||
import RichTextKit | ||
import SnapKit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
получится без снапкита сделать?
import RichTextKit | ||
import SnapKit | ||
|
||
final class RichTextViewController: UIViewController { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
получится переделать с UIViewController на UIView?
barButton.isSelected.toggle() | ||
|
||
if barButton.isSelected == true { | ||
richTextView.setRichTextStyle(style, to: barButton.isSelected) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
вот это можно вынести из if/else и написать лишь один раз
barButton.tintColor = .systemBlue | ||
} else { | ||
richTextView.setRichTextStyle(style, to: barButton.isSelected) | ||
barButton.tintColor = .none |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
вот это можно переписать на barButton.tintColor = barButton.isSelected ? .systemBlue : .none
guard let barButton else { return } | ||
barButton.isSelected.toggle() | ||
|
||
if barButton.isSelected == true { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
в таких случаях просто пиши if barButton.isSelected
boldButton?.isSelected = richTextView.richTextStyles.contains(.bold) ? true : false | ||
italicButton?.isSelected = richTextView.richTextStyles.contains(.italic) ? true : false | ||
strikethroughButton?.isSelected = richTextView.richTextStyles.contains(.strikethrough) ? true : false | ||
underlinedButton?.isSelected = richTextView.richTextStyles.contains(.underlined) ? true : false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
вот это все можно переписать так:
boldButton?.isSelected = richTextView.richTextStyles.contains(.bold)
(и для других кнопок также)
added toolbar, text styling using toolbar buttons and text formatting within a specific range