Eri*_*tto 9 iphone xcode cocoa-touch objective-c uinavigationbar
我正在尝试重新定位我的位置UIBarButtonItem
,使其位于UINavigationBar顶部和右侧的边缘.我找到了关于如何做到这一点的接受答案,但我真的不明白如何编码.
我开始创建一个名为CustomNavBar
继承自的新类UINavigationBar
.然后我将此方法放在实现中:
- (void) layoutSubviews
{
}
Run Code Online (Sandbox Code Playgroud)
我不明白的是答案中的部分
call [super layoutSubviews] and then find and reposition the button's view.
Run Code Online (Sandbox Code Playgroud)
我该如何编码呢?即使是正确方向的推动也会有所帮助.谢谢!
voi*_*ern 16
在你打电话后找到你想要移动的按钮,layoutSubviews
因为它会被重新定位到每次layoutSubviews
调用iOS时想要的位置.
- (void) layoutSubviews
{
[super layoutSubviews];
for (UIView *view in self.subviews) { // Go through all subviews
if (view == buttonYouWant) { // Find the button you want
view.frame = CGRectOffset(view.frame, 0, -5); // Move it
}
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
20379 次 |
最近记录: |