import ui
from objc_util import *
v = ui.View()
def b_action(sender):
print(sender)
b = ui.ButtonItem()
b.action = b_action
# set a ButtonItem custom view as an ui.Button where we can, via ObjectiveC
# put its title (label text) as multilines
vv = ui.Button()
vv.title = 'aaa\nbbb'
vv.tint_color = 'green'
vv.action = b_action
vv.frame = (0,0,100,32)
vvo = ObjCInstance(vv)
for sv in vvo.subviews():
if hasattr(sv,'titleLabel'):
tl = sv.titleLabel()
tl.numberOfLines = 0
tl.adjustsFontSizeToFitWidth = True # auto resize font to fit
break
ObjCInstance(b).customView = vvo
v.right_button_items = (b,)
v.present()
