All Projects → jkpang → Ppbadgeview

jkpang / Ppbadgeview

Licence: mit
iOS Custom Badge, Support UIView, UITabBarItem, UIBarButtonItem ,Support Objective-C/Swift; iOS自定义Badge组件, 支持UIView, UITabBarItem, UIBarButtonItem, 支持Objective-C/Swift

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Ppbadgeview

ETBadge
A tool of swift to add or clear badge for any UIView。You can use it easily, also can custom it.
Stars: ✭ 19 (-97.65%)
Mutual labels:  uiview, badge
BadgeControl
Badge view with controller written in Swift 5.0
Stars: ✭ 53 (-93.43%)
Mutual labels:  uiview, badge
Nakplaybackindicatorview
A UIView that mimics the music playback indicator in the Music.app on iOS 7+
Stars: ✭ 394 (-51.18%)
Mutual labels:  uiview
Badgenumbermanager
An Android library supports badge notification like iOS in Huawei, Xiaomi, OPPO and vivo launchers.
Stars: ✭ 617 (-23.54%)
Mutual labels:  badge
Badgen
Fast handcraft svg badge generator.
Stars: ✭ 464 (-42.5%)
Mutual labels:  badge
Swiftuikitview
Easily use UIKit views in your SwiftUI applications. Create Xcode Previews for UIView elements
Stars: ✭ 398 (-50.68%)
Mutual labels:  uiview
Stateview
UIViews that update themselves when your data changes, like React.
Stars: ✭ 493 (-38.91%)
Mutual labels:  uiview
Shadowview
An iOS Library that makes shadows management easy on UIView.
Stars: ✭ 391 (-51.55%)
Mutual labels:  uiview
Bootstrap Maxlength
This plugin integrates by default with Twitter bootstrap using badges to display the maximum lenght of the field where the user is inserting text. Uses the HTML5 attribute "maxlength" to work.
Stars: ✭ 743 (-7.93%)
Mutual labels:  badge
Badge Poser
The PHP badges, renders some badges for your readme with the packagist information.
Stars: ✭ 440 (-45.48%)
Mutual labels:  badge
Navigationtabbar
Navigation tab bar with colorful interactions.
Stars: ✭ 4,907 (+508.05%)
Mutual labels:  badge
Badgebutton
带有徽标(数字,小红点)的按钮
Stars: ✭ 434 (-46.22%)
Mutual labels:  badge
Badgeview
支持自由定制外观、拖拽消除的MaterialDesign风格Android BadgeView
Stars: ✭ 3,966 (+391.45%)
Mutual labels:  badge
Tokei
Count your code, quickly.
Stars: ✭ 5,896 (+630.61%)
Mutual labels:  badge
Substats
📈📉 Shhhh...we're counting your subscribers!
Stars: ✭ 396 (-50.93%)
Mutual labels:  badge
Badgeview
a BadeView base on android
Stars: ✭ 654 (-18.96%)
Mutual labels:  badge
Flutter badges
A flutter package for creating badges.
Stars: ✭ 391 (-51.55%)
Mutual labels:  badge
Svg2shenzhen
Convert Inkscape SVG drawings to KiCad PCB and footprint modules
Stars: ✭ 413 (-48.82%)
Mutual labels:  badge
Dsltablayout
♥️ Android界最万能的TabLayout(不仅仅是TabLayout), 支持任意类型的item, 支持Drawable类型的指示器,智能开启滚动,支持横竖向布局等
Stars: ✭ 489 (-39.41%)
Mutual labels:  badge
Viewanimator
ViewAnimator brings your UI to life with just one line
Stars: ✭ 6,592 (+716.85%)
Mutual labels:  uiview

PPBadgeView

iOS Custom Badge, Support UIView, UITabBarItem, UIBarButtonItem

iOS自定义Badge组件, 支持UIView, UITabBarItem, UIBarButtonItem以及子类

原理请戳: 掘金地址简书地址

iPhone

Requirements 要求

  • iOS 8+
  • Xcode 8+

Installation 安装

1.手动安装:

下载/Download PPBadgeView Demo
  • Objective-C : 拖入PPBadgeView/objc文件夹中的.h与.m文件, #import "PPBadgeView.h" 开始使用

  • Swift : 拖入PPBadgeView/swift文件夹中的.swift文件开始使用

  • Objective-C: dragged  into the .h file with the .m file in the PPBadgeView / objc folder,  #import "PPBadgeView.h" then,start using

  • Swift: Drag the .swift file into the PPBadgeView / swift folder to get start

2.CocoaPods安装:

  • Objective-C : pod 'PPBadgeView' then #import <PPBadgeView.h>
  • Swift : pod 'PPBadgeViewSwift' then import PPBadgeViewSwift

如果发现pod search PPBadgeView/PPBadgeViewSwift 不是最新版本,在终端执行pod setup命令更新本地spec镜像缓存(时间可能有点长),重新搜索就OK了

If you find pod search PPBadgeView / PPBadgeViewSwift is not the latest version, in the terminal  of the pod setup command to update the local spec image cache and re-search. (it may take you a long time)

3.Carthage (Swift):

// Cartfile
github "jkpang/PPBadgeView" ~> 3.0.0

// Terminal
carthage update --platform iOS

Usage 使用方法

1. Objective-C :
view = UIView, UITabBarItem, UIBarButtonItem及其子类(subclass)

// 添加带文本内容的Badge, 默认右上角, 红色, 18pts
// Add Badge with text content, the default upper right corner, red backgroundColor, 18pts
[view pp_addBadgeWithText:@"99+"];

// 添加带数字的Badge, 默认右上角,红色,18pts
// Add the Badge with numbers, the default upper right corner, red backgroundColor, 18pts
[view pp_addBadgeWithNumber:1];

// 添加带颜色的小圆点, 默认右上角, 红色, 8pts
// Add small dots with color, the default upper right corner, red backgroundColor, 8pts
[view pp_addDotWithColor:nil];

/**
 设置Badge的高度,因为Badge宽度是动态可变的,通过改变Badge高度,其宽度也按比例变化,方便布局
(注意: 此方法需要将Badge添加到控件上后再调用!!!)
Set the height of Badge, because the Badge width is dynamically and  variable.By changing the Badge height in proportion to facilitate the layout.
(Note: this method needs to add Badge to the controls and then use it !!!)

 @param points 高度大小
 */
[view pp_setBadgeHeight:25];

/**
 设置Badge的偏移量, Badge中心点默认为其父视图的右上角
 Set Badge offset, Badge center point defaults to the top right corner of its parent view
 
 @param x X轴偏移量 (x<0: 左移, x>0: 右移) axis offset (x <0: left, x> 0: right)
 @param y Y轴偏移量 (y<0: 上移, y>0: 下移) axis offset ( Y <0: up, y> 0: down)
 */
[view pp_moveBadgeWithX:-7 Y:5];

/**
 设置Badge的属性
 */
[view pp_setBadgeLabelAttributes:^(PPBadgeLabel *badgeLabel) {
        badgeLabel.backgroundColor = [UIColor redColor];
        badgeLabel.font =  [UIFont systemFontOfSize:13];
        badgeLabel.textColor = [UIColor blueColor];
    }];

// 数字增加/减少, 注意:以下方法只适用于Badge内容为纯数字的情况
// Digital increase /decrease, note: the following method applies only to cases where the Badge content is purely numeric
[view pp_decrease];
[view pp_increase];
2. Swift :
view = UIView, UITabBarItem, UIBarButtonItem及其子类

// 添加带文本内容的Badge, 默认右上角, 红色, 18pts
// Add Badge with text content, the default upper right corner, red backgroundColor, 18pts
view?.pp.addBadge(text: "99+");

// 添加带数字的Badge, 默认右上角,红色,18pts
// Add the Badge with numbers, the default upper right corner, red backgroundColor, 18pts
view?.pp.addBadge(number: 1);

// 设置Badge的高度,因为Badge宽度是动态可变的,通过改变Badge高度,其宽度也按比例变化,方便布局
// (注意: 此方法需要将Badge添加到控件上后再调用!!!)
// Set the height of Badge, because the Badge width is dynamically and  variable.By changing the Badge height in proportion to facilitate the layout.
// (Note: this method needs to add Badge to the controls and then use it !!!)
view?.pp.setBadgeHeight(21.0);

/// 设置Badge的偏移量, Badge中心点默认为其父视图的右上角 Set Badge offset, Badge center point defaults to the top right corner of its parent view
///
/// - Parameters:
///   - x: X轴偏移量 (x<0: 左移, x>0: 右移) axis offset (x <0: left, x> 0: right)
///   - y: Y轴偏移量 (y<0: 上移, y>0: 下移) axis offset ( Y <0: up, y> 0: down)
view?.pp.moveBadge(x: -7, y: 5)

// 自定义badge的属性: 字体大小/颜色, 背景颜色...(默认系统字体13,白色,背景色为系统badge红色)
// Custom badge properties: font size / color, background color... (default system font 13, white, background color is system Badge Red)
view?.pp.badgeView.textLabel.font = UIFont.systemFont(ofSize: 13)
view?.pp.badgeView.textLabel.textColor = UIColor.blue

// 数字增加/减少, 注意:以下方法只适用于Badge内容为纯数字的情况
// Digital increase /decrease, note: the following method applies only to cases where the Badge content is purely numeric
view?.pp.decrease()
view?.pp.increase()

更多的用法请查看Demo

CocoaPods更新日志

• 2018.09.13(tag:2.2.0):
  支持Xcode10, Swift4.2 <-> support Xcode10 and Swift4.2
  
• 2018.04.10(tag:2.1.0):
  1. 支持Xcode9.3, Swift4.1 <-> support Xcode9.3 and Swift4.1
  2. Update
  Objc:  - (void)pp_setBadgeHeightPoints:(CGFloat)points 
     ==> - (void)pp_setBadgeHeight:(CGFloat)height
     
  Swift: func setBadgeHeight(points: CGFloat)
     ==> func setBadge(height: CGFloat)
  
  3. Add: (fix issus #8: https://github.com/jkpang/PPBadgeView/issues/8)
  Objc: - (void)pp_setBadgeFlexMode:(PPBadgeViewFlexMode)flexMode;
  Swift: func setBadge(flexMode: PPBadgeViewFlexMode = .tail)
  
• 2017.09.23(tag:2.0.0):
  支持iOS11, Swift4 <-> support iOS11 and Swift4
  
• 2017.08.28(tag:1.1.2-PPBadgeViewSwift):
  修复PPBadgeViewSwift给UITabBarItem会崩溃的bug <-> Fix PPBadgeViewSwift to UITabBarItem will crash bug
  
• 2017.06.27(tag:1.1.1):
  添加英文注释 <-> Add English comments

• 2017.06.27(tag:1.1.0):
  移除私有API属性"UITabBarSwappableImageView"代码;
  Removes the private API property "UITabBarSwappableImageView" code
  
• 2017.06.21(tag:1.0.0):
  初始化到CocoaPods <-> Initialize to CocoaPods

我的App <-> My APP

  • PPHub:一个简洁漂亮的 GitHub iOS客户端 <-> A simple and beautiful GitHub iOS client
    App_Store

联系方式:

PP-iOS学习交流群群二维码

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].