如何以编程方式创建固定空间和灵活的空格键按钮项?
问题描述:
我想以编程方式创建 UIBarButtonItems
并将这些固定空格项放在按钮之间。
I want to create UIBarButtonItems
programmatically and place these fixed space items between buttons.
答
UIBarButtonItem *fixedItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
fixedItem.width = 20.0f; // or whatever you want
UIBarButtonItem *flexibleItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];