Re: How to constrain a UISlider in a UIToolbar?
Re: How to constrain a UISlider in a UIToolbar?
- Subject: Re: How to constrain a UISlider in a UIToolbar?
- From: "Gerriet M. Denkmann" <email@hidden>
- Date: Thu, 31 Jul 2014 11:00:00 +0700
On 31 Jul 2014, at 00:18, David Duncan <email@hidden> wrote:
>> That's the purpose of setting the auto-resizing mask to FlexibleWidth. At least for title views, that causes UINavigationBar to send -sizeThatFits: to the view.
>
> For UINavigationBar you shouldn’t need to even set flexible width, just implement -sizeThatFits:. Unfortunately UIToolbar does not call -sizeThatFits: for the views of bar button items.
>
> Gerriet, you can try setting the frame of the slider then calling -setNeedsLayout/-layoutIfNeeded on the toolbar to update the layout. If you do this within the standard layout callbacks it should go along with any animation that is already going.
Following your suggestion I changed my code to:
override func viewWillLayoutSubviews() // manage slider in bottomToolBar
{
// current width of toolbar is all wrong. Need to do:
bottomToolBar.setNeedsLayout()
bottomToolBar.layoutIfNeeded()
// now the toolbar width seems to be right
let b = bottomToolBar.frame.size.width
speedSlider.frame.size.width = b - 40
bottomToolBar.setNeedsLayout()
bottomToolBar.layoutIfNeeded()
}
Works perfectly now. Thanks a lot!
Kind regards,
Gerriet.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden