You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thank you for such an incredible library.
My issue:
In some cases, the text (it's arabic text) goes out of bounds and I can't understand why.
I tried calling sizeToFit, but it didn't help.
I attach a screenshot and a code
import UIKit
import PinLayout
finalclassAyahCell:UITableViewCell{//MARK: Static properties/// Верхний отступ для arabicLabel (12)staticlettopMargin:CGFloat=12/// Нижний отступ для arabicLabel (3)staticletbottomMargin:CGFloat=3/// Левый отступ для numberView (8)staticletleftMargin:CGFloat=8/// Правый отступ для arabicLabel (12)staticletrightMargin:CGFloat=8/// Левый отступ для arabicLabel (5)staticletarabicLabelLeftMargin:CGFloat=5/// Верхний отступ для numberView (5)staticletnumberViewTopMargin:CGFloat=5/// Высота для numberView (35)staticletnumberViewWidth:CGFloat=35/// Максимальная ширина arabicLabelstaticletmaxWidth=UIScreen.main.bounds.width - AyahCell.leftMargin - AyahCell.rightMargin - AyahCell.numberViewWidth - AyahCell.arabicLabelLeftMargin
//MARK: - ViewsprivateletseparatorView=UIView()privateletnumberView=UIView()privateletnumberImageView=UIImageView(image:AyahCellResources.numberImage)privateletarabicLabel:UILabel={letlabel=UILabel(textAlignment:.right, numberOfLines:0)return label
}()privateletnumberLabel:UILabel={letlabel=UILabel(textAlignment:.center, font:UIFont(name:"Georgia", size:14), numberOfLines:1)return label
}()//MARK: - PropertiesvarcellModel:AyahCellModel!//MARK: Initoverrideinit(style:UITableViewCell.CellStyle, reuseIdentifier:String?){
super.init(style: style, reuseIdentifier: reuseIdentifier)
selectionStyle =.none
contentView.addSubview(separatorView)
separatorView.pin.height(1)
contentView.addSubview(numberView)
numberView.addSubview(numberLabel)
numberView.addSubview(numberImageView)
contentView.addSubview(arabicLabel)}requiredinit?(coder:NSCoder){fatalError("init(coder:) has not been implemented")}//MARK: - Layoutoverridefunc layoutSubviews(){
super.layoutSubviews()layout()}privatefunc layout(){
separatorView.pin.top().left().right()
numberView.pin
.below(of: separatorView).marginTop(AyahCell.numberViewTopMargin).left(AyahCell.leftMargin).size(AyahCell.numberViewWidth)
numberImageView.pin.all()
numberLabel.pin.all()
arabicLabel
.pin
.after(of: numberView).marginLeft(AyahCell.arabicLabelLeftMargin).top(AyahCell.topMargin).right(AyahCell.rightMargin).bottom(AyahCell.bottomMargin)}}//MARK: SetupextensionAyahCell{func configure(with model:AyahCellModel){self.cellModel = model
letnumber="\(self.cellModel.ayahNumber)"self.arabicLabel.attributedText =self.cellModel.text
self.numberLabel.text = number
}}//MARK: Cell SizeextensionAyahCell{/// Атрибуты для арабского текстаstaticvararabicTextAtrributes:[NSAttributedString.Key:Any]{letparagraphStyle=NSMutableParagraphStyle()
paragraphStyle.lineSpacing =12
paragraphStyle.alignment =.right
paragraphStyle.lineBreakMode =.byWordWrapping
letattributes:[NSAttributedString.Key:Any]=[.foregroundColor :Theme.current.textColor,.font:ArabicFont.current.quranTextFont,.paragraphStyle : paragraphStyle]return attributes
}/// Расчет высоты для ячейки с текстом Коранаstaticfunc calculateCellHeight(text:NSMutableAttributedString)->CGFloat{letscreenWidth=UIScreen.main.bounds.width
letmaxWidth:CGFloat=
screenWidth - AyahCell.numberViewWidth - AyahCell.arabicLabelLeftMargin - AyahCell.leftMargin - AyahCell.rightMargin
letheight=(
text.size(maxWidth: maxWidth).height + AyahCell.topMargin + AyahCell.bottomMargin).rounded(.up)returnceil(height)}}
The text was updated successfully, but these errors were encountered:
Thank you for such an incredible library.
My issue:
In some cases, the text (it's arabic text) goes out of bounds and I can't understand why.
I tried calling sizeToFit, but it didn't help.
I attach a screenshot and a code
The text was updated successfully, but these errors were encountered: