tabbar的titlePositionAdjustment设置文字距离

2021-01-16 09:45:19

参考地址 iOS - tabbar的titlePositionAdjustment

  • 设置tabbar的item的文字的时有个属性
    titlePositionAdjustment

先看一个结构体:

typedef struct UIOffset {    CGFloat horizontal, vertical; // specify amount to offset a position, positive for right or down, negative for left or up
} UIOffset;1234
  • specify amount to offset a position, positive for right or down, negative for left or up
    这句话的意思:指定相应的数据去偏移一个位置,向右或者向下为正值,向左或者向上为负值,不过首先你得有一个相对位置的坐标。而tabbarItem文字的坐标是底部为x轴,y轴则是tabbarItem的centerX;
    直接上图,一下子就看明白了,不明白的话,再问。

  • 这个是titlelabel的相对坐标

坐标

  • 具体的实战例子,一眼看穿

title坐标

  • 附上设置的代码片段:

    vcOne.tabBarItem.titlePositionAdjustment  = UIOffsetMake(0, 0);
    vcTwo.tabBarItem.titlePositionAdjustment  = UIOffsetMake(0,10);
    vcThree.tabBarItem.titlePositionAdjustment= UIOffsetMake(10, 0);
    vcFour.tabBarItem.titlePositionAdjustment = UIOffsetMake(-10,-10);1234


  • 2017-10-13 16:21:29

    Activity的四种launchMode

    launchMode在多个Activity跳转的过程中扮演着重要的角色,它可以决定是否生成新的Activity实例,是否重用已存在的Activity实例,是否和其他Activity实例公用一个task里。这里简单介绍一下task的概念,task是一个具有栈结构的对象,一个task可以管理多个Activity,启动一个应用,也就创建一个与之对应的task。

  • 2017-10-16 16:45:45

    Android开发技巧:Application和Instance

    在开发过程中,我们经常会需要用到一些全局的变量或者全局的“管理者”,例如QQ,需要有一个“全局的管理者“保存好友信息,各个activity即可直接通过该”管理者“来获取和修改某个好友信息,显然,这样的一个好友信息,保存到某一个具体的activity里面,然后依靠activity的intent来传递参数是不合适。我们有两种方法来实现这样一个全局的管理者,一种是使用C++/Java中常用的单例模式,另一种是利用Android的Application类,下面一一阐述。

  • 2017-11-01 01:30:45

    解决第三方包内jar包冲突

    这个问题就是因为引入jar包的冲突,这时我们可以在build.gradle中添加如下代码,下方单独的是添加的代码

  • 2017-11-06 01:00:17

    撤销git add

    如何撤销git add,不小心执行了git add . 操作,但是又不能提交所有的文件,因为对应不同的分支,现在怎么样可以将git add 撤销回来

  • 2017-11-10 00:06:15

    CORS: credentials mode is 'include'

    XMLHttpRequest cannot load http://localhost/Foo.API/token. The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin 'http://localhost:5000' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.