简体   繁体   中英

How to get square hovering over button iOS

Sorry, the question isn't really clear, but basically I want a button or a label or something like that that says "notifications" and a small red square (like Facebook) that displays the number of notifications that user has (if they have any). How would I go about doing that? I'm not too advanced with UI design in iOS yet. I'm coming from an Android background so feel free to use any comparisons if there are any.

What you are referring to is called a badge. Some native controls have them (tab bar buttons come to mind), but most do not.

If you are using a tab bar controller, you can set the badge value from the UIViewController . Something like this:

[[self tabBarItem] setBadgeValue:@"1"];

If you are looking to implement a custom one, it could be easily accomplished with a UIView and a UILabel . Add a badge view to what ever view based control you are creating, then add a label to that badge view and set its text. There are probably lots of third party ones floating around the web already though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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