tabbar上的item的圖片和文字的調(diào)整

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);

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容