hendesi / SwiftTooltipKit

An out-of-the-box, easy-to-use and highly customizable tooltip kit for Swift

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Custom UI class not getting added.

sssuourabh opened this issue · comments

@hendesi When i am adding custom UI subclass of UIview then nothing is added.
`
final class TestingView: UIView {
private var headerLabel: UILabel = {
let label = UILabel()
label.textColor = UIColor.white
label.numberOfLines = 0
label.translatesAutoresizingMaskIntoConstraints = false
return label
}()

public override init(frame: CGRect) {
    super.init(frame: .zero)
    
    addSubview(headerLabel)
    backgroundColor = .green
    headerLabel.snp.makeConstraints { make in
        make.top.equalTo(4)
        make.leading.equalTo(4)
        make.trailing.equalTo(-4)
        make.height.equalTo(50)
        make.bottom.equalTo(-4)
    }

    headerLabel.text = "jdsbvb hehjeijiejijd ijeidjiejiejiojejdej edie jjd ijdijej de dede"
}

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

}
let nudge = TestingView()
sender.tooltip(nudge, orientation: .bottom)
`

Hi @sssuourabh!
Thanks for reaching out. It seems like there was an issue with the autolayout of the tooltip itself. I think I found the issue and pushed a fix to fix/custom-view. Please verify, if this solves your problem 👍

Also a small hint: Setting no preferredMaxLayoutWidth for your label, will result in the tooltip taking all of the screens width. Make sure to use preferredMaxLayoutWidth for your labels to give the tooltip a reasonable size.

Thanks, @hendesi . Works wow. Actually, i was looking to do something like that and was about to push, but thanks for the update. You saved my day.