简体   繁体   English

iOS-UILabel编辑,是否覆盖图像?

[英]iOS - UILabel editing, overlaying an image?

As you can probably tell from my last few questions, I am working on a screen that allows users to edit labels. 您可能从我的最后几个问题可以看出,我正在一个允许用户编辑标签的屏幕上工作。 Pages and all the other lovely apps have glorious resizing handles to show what label is currently being edited. Pages和所有其他可爱的应用程序均具有出色的调整大小手柄,以显示当前正在编辑的标签。

I am trying to get some feedback on the best way to do this. 我正在尝试获得有关最佳方法的反馈。 Is it possible to add an 'dot' image to the centre of all the edges of the label? 是否可以在标签所有边缘的中心添加“点”图像? Is it possible to change the background colour only in sections of a label? 是否可以仅在标签的部分中更改背景颜色? Or should I add an image on top of the label and disable it? 还是应该在标签顶部添加图片并将其禁用? The most important feature is for only the uilabel to respond to touches. 最重要的功能是仅uilabel响应触摸。 If I overlay an image, I want it to ignore the touch and hand it off to the label. 如果我覆盖图像,我希望它忽略触摸并将其交给标签。

Any feedback appreciated! 任何反馈表示赞赏! Cheers Guys! 大家好!

You will find as many opinions on this as there are programmers. 您会发现与程序员一样多的意见。 There is not built-in decoration for a view that shows the dot in the middle of each side. 在每边中间显示点的视图没有内置装饰。 But you can add that easily enough. 但是您可以轻松地添加它。 One way is instantiate four instances of an image with the dot and add them as subviews of the view you are decorating. 一种方法是用点实例化图像的四个实例,并将它们添加为要装饰的视图的子视图。 you can then set the center of each dot on the center of each edge in the parent view. 然后可以在父视图的每个边缘的中心设置每个点的中心。 As long as clipping is turned off in the parent view, these will show up (if they are not hidden ) even if they extend outside the frame of the parent view. 只要在父视图中关闭了剪切,即使它们延伸到父视图的框架之外,它们也会显示(如果未hidden )。

I don't understand what you want to accomplish by changing the background color in sections of the label view, but I this probably has some moderate complexity to it. 我不了解您要通过更改标签视图各部分中的背景色来实现什么,但是我可能对此具有一定的复杂性。

You can also to this with core graphics. 您也可以使用核心图形。 I'll stop there, though. 不过,我会停在那里。 There are literally many ways to do what you are trying to do. 从字面上看,有很多方法可以完成您想做的事情。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM