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

Change label attributes for FormLabelCell #66

Closed
danmartyn opened this issue Dec 14, 2017 · 4 comments
Closed

Change label attributes for FormLabelCell #66

danmartyn opened this issue Dec 14, 2017 · 4 comments

Comments

@danmartyn
Copy link

danmartyn commented Dec 14, 2017

I'm trying to create a Delete button row, by using a FormLabelCell and then setting the textAlignment to be centered and the textColor to be red. However, those changes don't seem to be working. I'm creating my section like this

let deleteSection = SectionFormer().append(rowFormer: LabelRowFormer<FormLabelCell>()
                .configure { row in
                    row.text = "Delete"
                    row.cell.textLabel?.textAlignment = .center
                    row.cell.textLabel?.textColor = .red
                }.onSelected { row in
                    if let indexPath = self.tableView.indexPath(for: row.cell) {
                        self.tableView.deselectRow(at: indexPath, animated: true)
                    }
                    self.startDeleteWorkflow()
            })
            self.former.append(sectionFormer: deleteSection)

When I run this, I get a FormLabelCell, but the "Delete" text is still left aligned and black, not red and centered. Any ideas?

@ZacharyKhan
Copy link
Collaborator

I'm assuming that self.startDeleteWorkflow() is where you are trying to update the cell. If that is the case, you need to call update() or cellUpdate() on the row.

Refer to the README to see how update() and cellUpdate() work.

@danmartyn
Copy link
Author

the startDeleteWorkflow function is where I create an action sheet to confirm if the user wants to do the deletion. Is changing the cell's text label in configure not the correct spot? I'm using update in my other section, but thats to change the content in a text field, not the attributes of it?

@ZacharyKhan
Copy link
Collaborator

ZacharyKhan commented Dec 14, 2017

I believe when you update the user interface of any row you should be using the update() or cellUpdate() function on the row.

Do you have a repo I can take a look at with the example code you're referring to?

@ZacharyKhan
Copy link
Collaborator

ZacharyKhan commented Feb 1, 2018

After reading this over once again, I think to accomplish your goal you should use a CustomRowFormer. Check the README and example with custom row, it isn't too complex IMO. If you need help with that, feel free to create a new issue.

If you still need to use LabelRowFormer for some reason, use one of the update() blocks on the cell to modify the cell and its subviews.

Closing due to inactivity.

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

No branches or pull requests

2 participants