简体   繁体   English

快速将自定义@IBDesignable视图的故事板指南标题设置为@IBInspectable值?

[英]Set the Storyboard guide title to a @IBInspectable value for a custom @IBDesignable view in swift?

I have a custom @IBDesignable UIButton. 我有一个自定义@IBDesignable UIButton。 I use several of them on a screen in the Storyboard file and they are central to the whole flow of the app. 我在Storyboard文件的屏幕上使用了其中的几个,它们对于整个应用程序流程至关重要。 They all appear in the Guide as "Button": 它们都在“指南”中显示为“按钮”:

"Button"s in guide 指南中的“按钮”

Seeing the actual title would be a whole lot easier in managing the Storyboard (although of course has no effect on actual runtime). 在管理情节提要时,看到实际标题会容易得多(尽管当然不会影响实际运行时)。 I'd like to set the title to an @IBInspectable label text I'm using: 我想将标题设置为我正在使用的@IBInspectable标签文本:

Their attribute Inspector 他们的属性检查器

I'm using my own label text instead of the regular button title because it's layout and format is special. 我使用自己的标签文本而不是常规按钮标题,因为它的布局和格式很特殊。 If I set the button title it shows up in the middle over the real title. 如果我设置按钮标题,它将显示在真实标题的中间。

Ideally I want to set the guide "title" to my label. 理想情况下,我想将指南“标题”设置为标签。 I couldn't find anything anywhere on how to do this. 关于如何执行此操作,我什么都找不到。 Otherwise, is there some work around trick to use the Button Label? 否则,是否有一些解决方法来使用按钮标签? Keep in mind this is just to make the Storyboard less confusing for others to see and use. 请记住,这只是为了使情节提要减少其他人查看和使用的混乱。

Thanks! 谢谢!

You can always slow double click each button (in the Document Outline (the left pane (your first picture))). 您总是可以缓慢地双击每个按钮(在“文档大纲”中(左窗格(您的第一张图片)))。 It'll let you rename it right there. 它会让您在此处重命名。

By "slow double click" I mean, click to select, wait a sec, click again (without moving the mouse). “慢速双击”是指单击以选择,等待一秒钟,然后再次单击(不移动鼠标)。

I'm only familiar with The Document Outline automatically naming things when you provide referencing outlets (control dragging to a .swift file). 当您提供引用出口(将控件拖到.swift文件)时,我只熟悉文档大纲自动为事物命名。 They'll take on the names of the variables you're dragging them to (even so far as formatting camel case with spaces and caps for you). 它们将采用您将其拖到的变量的名称(即使是格式化驼峰大小写的情况,也要使用空格和大写)。 Otherwise, in your case, you're probably going to have to manually name each one. 否则,就您而言,您可能将不得不手动命名每个名称。

You can "name" your elements by filling in the Label field in the Identity Inspector pane: 您可以通过填写“身份检查器”窗格中的“ Label字段来“命名”元素:

在此处输入图片说明

As you see, I have a normal UIButton, and I put "Button One" in the Label field... so it shows up as "Button One" in the outline pane. 如您所见,我有一个普通的UIButton,并且在Label字段中放置了“ Button One” ...,因此它在大纲窗格中显示为“ Button One”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Swift @ IBDesignable / @ IBInspectable UIView样式 - Swift @IBDesignable/@IBInspectable UIView styling Swift @IBDesignable - @IBInspectable多个变量 - Swift @IBDesignable - @IBInspectable multiple variables IBDesignable视图中的IBInspectable按钮 - IBInspectable button inside IBDesignable view IBInspectable / IBDesignable的Swift多继承解决方案? - Swift multiple inheritance solution for IBInspectable/IBDesignable? 在自定义视图类的情节提要中看不到IBInspectable自定义属性 - Unable to see the IBInspectable custom properties in Storyboard of the custom view class 我如何使用@IBDesignable和@IBInspectable创建uitextfield的自定义子类,并且可以在左侧设置placholder padding - How can I make a custom subclass of uitextfield and over there using @IBDesignable & @IBInspectable I can set placholder padding from left 如何使用@IBDesignable和@IBInspectable在UIView中自定义此图像选项卡更好 - How to custom this image tab in UIView,using @IBDesignable and @IBInspectable is better 约束更新图层后,调用@IBDesignable中设置的@IBInspectable - Call @IBInspectable set in @IBDesignable after layer is updated by constraints Swift无法通过@IBDesignable类设置视图的高度 - Swift cannot set view's height from @IBDesignable class 在UIViewController中使用IBDesignable和IBInspectable - Using IBDesignable and IBInspectable with UIViewController
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM