objective c - Size a UIToolbar to fit its items? -


i'm trying figure out clean way make uitoolbar wide needs to fit items contains. there way either:

  • configure uitoolbar adjust width automatically items changed?
  • programatically determine minimum width required items, can used set uitoolbar's frame?

i haven't been able figure out due spacing between items , fact uibarbuttonitems not uiview subclasses.

after trying suggestions other answers did not work unless used custom views, or unless loaded, arrived @ way set toolbar width based on items:

//add bar items toolbar first.  uiview* v = toolbar.subviews.lastobject; float newwidth = v.frame.origin.x + v.frame.size.width;  //set toolbar width 

you'll need override uitoolbar -setitems: or otherwise detect changed buttons autoresize.

i have included feature in refactoring library, es_ios_utils, set navigation item's right item multiple buttons. in preceding link, see uitoolbar +toolbarwithitems: , uinavigationitem -setrightbarbuttonitems.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -