All Projects → evgenyneu → Swift Badge

evgenyneu / Swift Badge

Licence: mit
A badge view for iOS/tvOS written in Swift

Programming Languages

swift
15916 projects

Labels

Projects that are alternatives of or similar to Swift Badge

repo-card
😎 showcase repositories on your website 🤘!
Stars: ✭ 141 (-62.8%)
Mutual labels:  badge
Yeebadge
badgeView for UIView Inspired by WZLBadge,using UIImage to avoid off-screen rendering
Stars: ✭ 33 (-91.29%)
Mutual labels:  badge
Kratos Boilerplate
🔥 A simple boilerplate for creating statics PWA using Webpack, Pug, PostCSS and CSS Modules
Stars: ✭ 308 (-18.73%)
Mutual labels:  badge
qpage
👨‍💻 Free Project For Creating Academic Homepage Without Any Code In 3min
Stars: ✭ 87 (-77.04%)
Mutual labels:  badge
Expo-Badge
A design study for Expo badges
Stars: ✭ 22 (-94.2%)
Mutual labels:  badge
ETBadge
A tool of swift to add or clear badge for any UIView。You can use it easily, also can custom it.
Stars: ✭ 19 (-94.99%)
Mutual labels:  badge
stats-cards
在 README 中展示你在知乎,GitHub,B 站,LeetCode,掘金,CSDN,牛客等网站的数据,服务部署在 Vercel 上,保证服务稳定。Show your LeetCode & GitHub stats in GitHub Profile.
Stars: ✭ 74 (-80.47%)
Mutual labels:  badge
Slwidget
轮子合集。角标、滚动选择器、自动换行布局、侧滑返回。
Stars: ✭ 363 (-4.22%)
Mutual labels:  badge
SuperBadge
🚀 📛 SuperBadge Android Library 🔥
Stars: ✭ 34 (-91.03%)
Mutual labels:  badge
Xamarin Forms Tab Badge
Xamarin Forms bindable Tab badges for iOS, Android, UWP, MacOS and WPF
Stars: ✭ 304 (-19.79%)
Mutual labels:  badge
badge-generator
Magically generate Markdown badges for your docs 🛡️ 🦡 🧙
Stars: ✭ 104 (-72.56%)
Mutual labels:  badge
badgecreatr
Quickly place relevant badges at the top of your readme, stop copy pasting, start on your project
Stars: ✭ 61 (-83.91%)
Mutual labels:  badge
made-with-love-in
🛠️ ❤️ 🗺️ 🛡️ — Mircoservice for serving and listing "Made with love in <country-name>" badges
Stars: ✭ 21 (-94.46%)
Mutual labels:  badge
langauge
🎨 Stylize your readme files with colorful gauges
Stars: ✭ 16 (-95.78%)
Mutual labels:  badge
Gorganizer
Organize your folders into a beautiful classified folder structure with this perfect tool
Stars: ✭ 318 (-16.09%)
Mutual labels:  badge
github-profile-achievements
A collection listing all Achievements available on the GitHub profile 🏆
Stars: ✭ 1,060 (+179.68%)
Mutual labels:  badge
badgemaker
The Nim badgemaker tool.
Stars: ✭ 15 (-96.04%)
Mutual labels:  badge
Open Source Badges
Open Source & Licence Badges
Stars: ✭ 368 (-2.9%)
Mutual labels:  badge
Handycontrols
Contains some simple and commonly used WPF controls based on HandyControl
Stars: ✭ 347 (-8.44%)
Mutual labels:  badge
Badge Size
🍻 Displays the size of a given file in your repository.
Stars: ✭ 277 (-26.91%)
Mutual labels:  badge
Swift Badge

A badge control for iOS and tvOS written in Swift

Carthage compatible CocoaPods Version License Platform

  • The badge is a subclass of UILabel view.
  • It can be created and customized from the Storyboard or from the code.

Setup

There are various ways you can add BadgeSwift to your Xcode project.

Add source (iOS 7+)

Simply add BadgeSwift.swift file to your project.

Setup with Carthage (iOS 8+)

Alternatively, add github "evgenyneu/swift-badge" ~> 8.0 to your Cartfile and run carthage update.

Setup with CocoaPods (iOS 8+)

If you are using CocoaPods add this text to your Podfile and run pod install.

use_frameworks!
target 'Your target name'
pod 'BadgeSwift', '~> 8.0'

Setup with Swift Package Manager

Legacy Swift versions

Setup a previous version of the library if you use an older version of Swift.

Usage

Creating a badge in the Storyboard

  • Drag a Label to your view.
  • Set its class to BadgeSwift in identity inspector.
  • Set the module property to BadgeSwift (unless you used the file setup method).
Add badge to storyboard
  • Customize the badge properties in the attributes inspector (text, color and other).
  • If storyboard does not show the badge correctly click Refresh All Views from the Editor menu.
Change badge properties in attribute inspector

Note: Carthage setup method does not allow to customize Cosmos view from the storyboard, please do it from code instead.

Creating a badge from the code

Add import BadgeSwift to your source code unless you used the file setup method.

let badge = BadgeSwift()
view.addSubview(badge)
// Position the badge ...

See example of how to create and position the badge from code in the demo app.

Customization

// Text
badge.text = "2"

// Insets
badge.insets = CGSize(width: 12, height: 12)

// Font
badge.font = UIFont.preferredFont(forTextStyle: UIFontTextStyle.body)

// Text color
badge.textColor = UIColor.yellow

// Badge color
badge.badgeColor = UIColor.black

// Shadow
badge.shadowOpacityBadge = 0.5
badge.shadowOffsetBadge = CGSize(width: 0, height: 0)
badge.shadowRadiusBadge = 1.0
badge.shadowColorBadge = UIColor.black

// No shadow
badge.shadowOpacityBadge = 0

// Border width and color
badge.borderWidth = 5.0
badge.borderColor = UIColor.magenta

// Customize the badge corner radius.
// -1 if unspecified. When unspecified, the corner is fully rounded. Default: -1.
badge.cornerRadius = 10

Demo app

This project includes a demo app.

BadgeSwift for iOS demo app Show BadgeSwift in a table view in iOS Create badge from code BadgeSwift for iOS

Alternative solutions

Here are some alternative badges for iOS.

Thanks to 👍

  • amg1976 for adding a border and redesigning the drawing.
  • gperdomor for adding ability to customize corner radius.
  • acecilia for removing a warning when the badge is used in an extension.

License

BadgeSwift is released under the MIT License.

Feedback is welcome

If you found a bug or want to improve the badge feel free to create an issue.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].