1.設(shè)置tabbar的item的文字的時(shí)有個(gè)屬性
titlePositionAdjustment
先看一個(gè)結(jié)構(gòu)體:
typedef struct UIOffset {
CGFloat horizontal, vertical; // specify amount to offset a position, positive for right or down, negative for left or up
} UIOffset;
specify amount to offset a position, positive for right or down, negative for left or up
這句話(huà)的意思:指定相應(yīng)的數(shù)據(jù)去偏移一個(gè)位置,向右或者向下為正值,向左或者向上為負(fù)值,不過(guò)首先你得有一個(gè)相對(duì)位置的坐標(biāo)。而tabbarItem文字的坐標(biāo)是底部為x軸,y軸則是tabbarItem的centerX;
直接上圖,一下子就看明白了,不明白的話(huà),再問(wèn)。
這個(gè)是titlelabel的相對(duì)坐標(biāo)
具體的實(shí)戰(zhàn)例子,一眼看穿
附上設(shè)置的代碼片段:
vcOne.tabBarItem.titlePositionAdjustment? = UIOffsetMake(0, 0);
vcTwo.tabBarItem.titlePositionAdjustment? = UIOffsetMake(0,10);
vcThree.tabBarItem.titlePositionAdjustment= UIOffsetMake(10, 0);
vcFour.tabBarItem.titlePositionAdjustment = UIOffsetMake(-10,-10);
2.設(shè)置圖片的偏移
vcOne.tabBarItem.imageInsets = UIEdgeInsetsMake(2, 2, 2, 2);