button.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0);
这样是不能把文字贴近button的边缘的。
亲测可用:
//设置UIButton字体居左显示
button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
//设置UIButton字体居右显示
button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;