Skip to content
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

Changing tokenView's frame #10

Open
mrfarukturgut opened this issue Jul 10, 2018 · 4 comments
Open

Changing tokenView's frame #10

mrfarukturgut opened this issue Jul 10, 2018 · 4 comments

Comments

@mrfarukturgut
Copy link

I want to change tokenView's frame in .cellSetup and row's constructor by setting $0.cell.tokenView.frame. However neither of them worked. Can you help?

@mats-claassen
Copy link
Member

The tokenView is positioned using constraints so that you cannot change its frame.
You will have to subclass TokenCell to change that.

Also the cell should be set up in cellSetup, and not during the row's initializer.

@mrfarukturgut
Copy link
Author

I tried to change frame of tokenView in this var;

lazy public var tokenView: CLTokenInputView = { [weak self] in
        guard let me = self else { return CLTokenInputView() }
        let tokenView = CLTokenInputView(frame: me.frame)
        tokenView.frame = CGRect(..)
        tokenView.translatesAutoresizingMaskIntoConstraints = false
        //tokenView.accessoryView = nil
        tokenView.delegate = me
        return tokenView
        }()

However it did not work. Can you please provide a simple snippet of subclassing TokenCell

@mats-claassen
Copy link
Member

As I said you must change the constraints. Haven't tested it but something like this:

class CustomCell<T, CollectionViewCell: UICollectionViewCell>: CollectionTokenCell<T, CollectionViewCell> where CollectionViewCell: EurekaTokenCollectionViewCell, CollectionViewCell.T == T {

    required public init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
    }

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

    override func setupConstraints() {
        // add custom constraints
        // like
        // let views = ["tokenView": tokenView]
        // contentView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|[tokenView]|", options: .alignAllLastBaseline, metrics: nil, views: views))
        // contentView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|[tokenView]|", options: .alignAllLastBaseline, metrics: nil, views: views))
    }
}

final class CustomAccessoryRow<T: TokenSearchable>: _TokenRow<T, CustomCell<T, TRCollectionViewCell<T>>>, RowType {
    required init(tag: String?) {
        super.init(tag: tag)
    }
}

@mrfarukturgut
Copy link
Author

Ok! Last question, what about changing the fonts and sizes of placeholder and tokens?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants