How to read a UILabel through UIButtons (that have no text)

时间:2016-02-12 21:15:14

标签: ios swift uibutton uilabel

I am trying to see the amount of points (times I have clicked the object3.dir.file=c:\resources\open ) using a UIButtons, but I can only see the number until a UILabel spawns on it. Even if I click on the UIButton, it will "disappear," really just turn black like the UIButton, but will still be blocking the self.view.backgroundColor's text from being seen.

Is there any simple solutions to this, or would the best way to be just to not allow squares to spawn there, but then you would not be able to do UILabel for it would be even harder to click.

enemy.center

2 个答案:

答案 0 :(得分:0)

You can set the label's zIndex to a higher number so that it's always "in front" of any buttons that may spawn in the exact same spot. The default is 0, so if you set the label's zIndex to 1 the buttons will spawn underneath it.

答案 1 :(得分:0)

If you want to be able to see the label when it's behind a button, you could set the public static String getUTCDate() { final TimeZone timeZone = TimeZone.getTimeZone("UTC"); final Calendar calendar = Calendar.getInstance(timeZone); final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("YYYY-MM-dd'T'HH:mm:ss.SSS'Z'"); simpleDateFormat.setTimeZone(timeZone); return simpleDateFormat.format(calendar.getTime()); } to ackgroundColor instead of UIColor.clearColor()

You could also move your .blackColor() to a view that is at the top of the screen, and have all your "enemies" spawn in a view below that. You would have to modify scoreLabel to take a different size into account, but that might be better than trying to see through your buttons.