【问题标题】:Custom tab bar setting the frame and position自定义标签栏设置框架和位置
【发布时间】:2011-03-28 05:05:10
【问题描述】:

我目前正在制作我的自定义标签栏。它工作正常,我这样做的方式是隐藏默认栏。我准备好了图像,打开和关闭的图像。 似乎通过使用将这些实现到主要概念中:

btn3.frame = CGRectMake(240, 430, 80, 50);

每个 CGRectMake 的数字组合都是唯一的。我已经做到了,但我在栏上使用了 3 个按钮。本教程使用四个。如果我使用 3 个按钮而不是 4 个按钮,我应该为每个 CGRectMake 设置什么数字组合。因为我假设组合彼此成比例,具体取决于有多少个选项卡。就是设置按钮/选项卡的框架大小和位置。

我将这些用于我的标签,但我之间有一个差距。 btn1.frame = CGRectMake(0, 430, 80, 50); btn2.frame = CGRectMake(160, 430, 80, 50); btn3.frame = CGRectMake(240, 430, 80, 50);

http://www.rumexit.co.uk/2010/11/how-to-customise-the-tab-bar-uitabbar-in-an-iphone-application-part-2-of-2/

它在页面的第四个框中。

【问题讨论】:

    标签: iphone objective-c c


    【解决方案1】:
    // Pseudocode.
        int numButtons = 3;
        float buttonWidth = self.view.frame.size.width / numButtons;
    
        btn1.frame = CGRectMake(0 * buttonWidth, 430, buttonWidth, 50); btn2.frame = CGRectMake(1 * buttonWidth, 430, buttonWidth, 50); btn3.frame = CGRectMake(2 * buttonWidth, 430, buttonWidth, 50);
    

    【讨论】:

    • 我试过这个,我得到错误 'CGRect' has no member named 'width'。
    • 这是伪代码,因为我不知道您从哪里调用它。试试 self.view.frame.size.width。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-21
    • 1970-01-01
    相关资源
    最近更新 更多