Текст не переноситсяIOS

Программируем под IOS
Ответить
Anonymous
 Текст не переносится

Сообщение Anonymous »

У меня есть следующий текст в поле. Проверьте скриншот. По какой-то причине текст не переносится, хотя у меня есть следующий код. Как это исправить?

Код: Выделить всё

import Foundation
import UIKit
import SDWebImage

// MARK: - Custom Collection View Cell
class CollectionViewCell: UICollectionViewCell {

private let imageView = UIImageView()
private let titleLabel = UILabel()

override init(frame: CGRect) {
super.init(frame: frame)

// ImageView Setup
imageView.contentMode = .scaleAspectFill
imageView.clipsToBounds = true
imageView.layer.masksToBounds = true

// Title Label Setup
titleLabel.font = UIFont(name: "Inter-Regular", size: 16)
titleLabel.textColor = .black
titleLabel.textAlignment = .left
titleLabel.lineBreakMode = .byWordWrapping
titleLabel.numberOfLines = 0

contentView.addSubview(imageView)
contentView.addSubview(titleLabel)

contentView.backgroundColor = .white
contentView.layer.cornerRadius = 8
contentView.layer.borderWidth = 1
contentView.layer.borderColor = UIColor.lightGray.cgColor

imageView.translatesAutoresizingMaskIntoConstraints = false
titleLabel.translatesAutoresizingMaskIntoConstraints = false

NSLayoutConstraint.activate([
imageView.topAnchor.constraint(equalTo: contentView.topAnchor),
imageView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor),
imageView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor),
imageView.heightAnchor.constraint(equalToConstant: 100),

titleLabel.topAnchor.constraint(equalTo: imageView.bottomAnchor, constant: 8),
titleLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 10),
titleLabel.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: 10),
titleLabel.bottomAnchor.constraint(equalTo: contentView.bottomAnchor)
])
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

func configure(title: String, imageName: String) {
titleLabel.text = title
imageView.sd_setImage(with: URL(string: imageName), placeholderImage: UIImage(named: "personalfinance"))
}
}
Изображение


Подробнее здесь: https://stackoverflow.com/questions/793 ... oesnt-wrap
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «IOS»