Home Swift 3 own font for UITableViewCellActionButton
Reply: 1

Swift 3 own font for UITableViewCellActionButton

LarsGvB
1#
LarsGvB Published in 2017-11-14 18:00:51Z

this is my first question here, so feel free to point out anything I might be doing wrong ;)

I'm currently trying to give the UITableViewRowAction-Buttons in my Application a custom font. For that I used David Seeks Answer here and put in in an extension like this:

extension UITableViewCell{

override open func layoutSubviews() {

    super.layoutSubviews()

    for subview in self.subviews {

        for sub in subview.subviews {

            if String(describing: sub).range(of: "UITableViewCellActionButton") != nil {

                for view in sub.subviews {

                    if String(describing: view).range(of: "UIButtonLabel") != nil {

                        if let label = view as? UILabel {

                            label.font = UIFont(name: "CaptureSmallz", size: label.font.pointSize)

}}}}}}}}

It works, but it seems to cut the space of the overlying cell elements: see screenshot Any ideas what I'm doing wrong here?

MQLN
2#
MQLN Reply to 2017-11-14 18:06:39Z

Try calling label.sizeToFit(), that should resize things after you've changed the label's font size.

This seems like a good place for a subclass of the UITableViewCell though, to achieve all the customization that you're looking for.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.352745 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO