- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试添加自定义控件作为 UINavigationBar 中的 titleView。当我这样做时,尽管设置了通常采用全宽的框架和属性,但我得到了:
亮蓝色可以忽略,因为它是我隐藏自定义控件的地方。问题是导航栏两端的窄条。我怎样才能摆脱这些,以便我的自定义 View 将拉伸(stretch) 100%?
CGRect frame = CGRectMake(self.view.bounds.origin.x, self.view.bounds.origin.y, self.view.width, kDefaultBarHeight);
UANavBarControlView *control = [[[UANavBarControlView alloc] initWithFrame:frame] autorelease];
control.autoresizingMask = UIViewAutoresizingFlexibleWidth;
self.navigationItem.titleView = control;
PS - 我知道我可以自行添加 View ,而不是附加到导航栏,并且自己定位它会非常容易。我有需要将其放置在导航栏“上”的原因,这些原因是 here
最佳答案
刚刚遇到了同样的问题,经过一番思考后解决了。 titleView 的框架每次出现时都会由 navigationBar 设置。
您所要做的就是子类化 UIView 并覆盖 setFrame
。
像这样:
- (void)setFrame:(CGRect)frame {
[super setFrame:CGRectMake(0.0, 0.0, 320.0, 50.0)];
}
现在将你偷偷摸摸的新 UIView 设置为 navigationItem.titleView
并享受它新发现的对 super View 调整大小的阻力。
您不必每次设置框架时都设置 super 框架。您只需设置一次即可完成。如果您想支持方向更改,您也可以将其组合在一起。
关于iphone - 如何获得全尺寸的 UINavigationBar titleView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3756395/
我已经在我的 navigation.titleView 中添加了一个搜索栏 self.navigationItem.titleView = searchBar 还有一个带有 title = "
我正在尝试使用以下代码在 UINavigationItem 上添加我的图像: override func viewDidLoad() { super.viewDidLoad()
Xamarin 新手,我正在尝试在我的跨平台应用程序中创建自定义导航栏。经过一些阅读,我发现我可以在我的 xaml 页面文件中使用标题 View 组件,如下所示。
我正在使用带有自定义 UIView 子类的导航,该子类成为我的 titleView。我想确保这是完整的可用宽度。 从我的 UIViewController 的 viewWillAppear: 逻辑上来
我发现有关使用 UINavigationItem#titleView 和自定义字体的信息很少。当我这样做时,导航栏中的字体垂直不对齐。 这篇文章的部分目的是记录黑客行为,也希望有人对这个问题有一个简洁
我正在尝试添加自定义控件作为 UINavigationBar 中的 titleView。当我这样做时,尽管设置了通常采用全宽的框架和属性,但我得到了: 亮蓝色可以忽略,因为它是我隐藏自定义控件的地方。
我正在尝试动态设置导航栏的文本,以便标题文本始终适合。我是这样完成的: // Pet's Day text "Joy's Day" if let range = currentPet.range(of
我想使用 UITextField 创建一个搜索栏。我尝试将 NavigationItem 的 TitleView 设置为文本字段并设置相应的约束。但导航栏中央的文本字段仍然很短。如何让文本框填满整个导
我正在学习一个 coursera 类(class),我真的到了我认为我不适合这个工作领域(开发)并且应该坚持图形设计的地步。至少我想完成这门类(class),但我不断收到我不明白的错误!根据 logc
我想在第一个 View Controller 的导航栏中添加一个 Logo ,但它的缩放效果很差,因为我不知道最大尺寸是多少。有谁知道吗? 顺便说一句,我知道创建全尺寸图像的技巧,但我不想这样做,我只
当方向改变时调整 UINavigationBar titleview 内容图像大小的最佳方法是什么。我有一张图像高度为 44 像素,另一张图像高度为 32 像素,在旋转 View 后,我更改标题 Vi
在自定义类 MMTimerButton 中,我将按钮设置为响应单击和双击 - (id)initWithFrame:(CGRect)frame { self = [super initWithF
我正在使用 Storyboard ,并将 UIView 添加到带有 2 个子 UILabels 的导航项。我希望 UIView 尽可能达到最大宽度。我注意到我无法使用自动布局来创建约束来执行此操作。这
我的目标是在导航 Controller 页面标题中使用不同字体大小的标题和副标题(标题应该更大,副标题应该相应地更低)。 我找到了实现此功能的代码示例。唯一的问题是未应用字体大小——标题和副标题的字体
我的应用程序适合放在 UINavigationController 中。简单地说,我将 MyUIViewController 设置为 navigationController 的 rootViewCo
我正在尝试推送一个 View Controller 并设置其导航栏的标题,但我猜是因为使用了很长的标题,所以它没有居中。与此同时,后退按钮的范围增加到标题 View ,即如果我点击 Milestone
我想用图像和文本设置 navigationItem 的 titleView,如下图所示: 我该如何实现? 更具体地说,我正在尝试在 Swift 中执行此操作。 最佳答案 条件,你的 Controlle
我有这样的东西: 但我需要为 titleView 设置的 View 在左侧和右侧没有这些边距。像这样: 这就是我实际做的: @property (nonatomic, strong) XHScroll
我在 UIViewController 扩展中使用这个函数来添加一个调整字体以适应宽度的标题。 extesion UIViewController { func setTitleDiffere
在我的 View Controller 中,我将 titleView 设置为 UIView,其中包含一个 UIImageView,使用 setCornerRadius 将其制成一个圆圈层。 圆的上半部
我是一名优秀的程序员,十分优秀!