TimOliver / TOSegmentedControl

A segmented control in the style of iOS 13 compatible with previous versions of iOS.
MIT License
197 stars 24 forks source link

Doesn't work correctly with "initWithCustomView:" on `UIBarButtonItem` in `UIToolbar` #7

Open benguild opened 5 years ago

benguild commented 5 years ago

Tried this out, and found that this didn't size correctly in this configuration. It squished whatever is on either side, and the buttons weren't visible.

TimOliver commented 5 years ago

G'day Ben! :D

Oh no. I might have screwed up one of the initialisers if the buttons weren't appearing. I just pushed a fix to master. See if it's still happening for you. :)

benguild commented 5 years ago

The buttons were appearing but they were massive. Normally within a UIBarButtonItem they'd be the minimum size but here they were taking up the whole bar.

TimOliver commented 5 years ago

Uhhhh. Hmm. That might be implicit behavior of the UIBarButtonItem when it's dealing with what it thinks is a vanilla UIView. I'm not sure if there's a way I can intelligently block that from within the codebase.

You sure you can't just resize the frame manually and use flexible width items on either side? :D

benguild commented 5 years ago

So to clarify, if I put UISegmentedControl (a view, heh) in instead it works and looks fine, but this takes up the entire bar's width and squishes all of the other items to nothing.

TimOliver commented 5 years ago

Sounds fine to me. 🙃

Yeah, I don't know. Maybe there's a layout property in UIKit where you can set the preferred content size of a view. I'd need to play with it, but I've got other iOS 13 fires to put out at the moment. 😅