Giter Site home page Giter Site logo

jkpang / ppbadgeview Goto Github PK

View Code? Open in Web Editor NEW
845.0 13.0 119.0 1.38 MB

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

License: MIT License

Objective-C 46.04% Swift 52.13% Ruby 1.83%
ios-badge uiview badge

ppbadgeview's Introduction

Hi there

Metrics

ppbadgeview's People

Contributors

damozhang avatar ixongju avatar jkpang avatar khala-wan avatar larromba avatar wcharysz-alten avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ppbadgeview's Issues

Value of type 'PP<UIBarButtonItem>' has no member 'setBadgeLabel' !

what happened to this function?

buttonItem?.pp.setBadgeLabel(attributes: { (badgeLabel) in
      badgeLabel.font = UIFont.systemFont(ofSize: 13)
      badgeLabel.textColor = UIColor.blue
})

in the last version and Swift 5
it gives me an error

Value of type 'PP' has no member 'setBadgeLabel'

小圆点无法移除

添加小圆点后无法移除
viewController.tabBarItem.pp.addDot(color: .red)
没有找到移除函数

iOS 9 tababr icon 飘了

WechatIMG7

如图所示

代码如下

    fileprivate func setBadge(num: String) {
        if let value = Int(num), value > 0 {
            self.viewControllers?.last?.tabBarItem.pp.addBadge(text: num)
        } else {
            self.viewControllers?.last?.tabBarItem.pp.hiddenBadge()
        }
    }

Swift5 + 3.0.0 版本 注释掉代码显示正常

Swift 5 Support w/ Cocoapods

Expected Results

No warning to convert PPBadgeViewSwift.framework to Swift 5

Actual Results

Xcode created warnings to convert PPBadgeViewSwift.framework to Swift 5

Steps to Reproduce

Build the cocoapod in Xcode 10.2

Grow badge on left if needed

Hi!
I'm trying to align the badge text to the right, but I'm unable to…
If you look at the screenshot, you'll see that the badge, when higher than 10, is touches the end of the screen. How can I tell the badge to grow on the left instead of right, or at least stay centered on the original badge center position?

simulator screen shot - iphone x - 2018-01-24 at 15 22 43

addBadge(number:xxx)命名建议

addBadge第一反应就是添加了一个View,所以当我的数字要改变时再次使用addBadge(number:)时就觉得是不是要先把原来的哪个badge先remove掉。层层点进去看才知道,在badge的get方法里有个防止重复创建的判断,这才放心。
所以本着避免歧义,对初使者更容易接受的出发点,建议后续更新考虑使用setBadge(number:)这种命名。

UITabBarItem+PPBadgeView not work in iOS 14

In iOS 14, can not add a badge view in UITabBarItem.
Debug the code ,we can see that :

- (UIView *)bottomView
{
    // 通过Xcode视图调试工具找到UITabBarItem原生Badge所在父视图
    UIView *tabBarButton = [self valueForKey:@"_view"];
    for (UIView *subView in tabBarButton.subviews) {
        if (subView.superclass == NSClassFromString(@"UIImageView")) {
            return subView;
        }
    }
    return tabBarButton;
}

The line code [self valueForKey:@"_view"] return nil.
Can not get a view as container for badge view.

swift版本兼容

啥时候进行版本迁移? 'Self' is only available in a protocol or as the result of a method in a class;

我觉得是否可以添加一个功能

就是99+这个,一般这种提示更加喜欢面对数字操作,但是肯定会有99+这种情况,是否可以给一个接口,类似maxCount这种字段,当超过最大数就显示xxx+,感觉还是挺易用的,当然只是我的一面之词了

iOS 13 TabBar红点偏移

如果之前有通过TabBar上图片位置来设置红点位置,在iOS13上会发现显示位置都在最左边去了。遍历UITabBarButton的subViews发现只有在TabBar选中状态下才能取到UITabBarSwappableImageView,解决办法是修改为通过UITabBarButton的位置来设置红点的frame。

https://www.jianshu.com/p/4654f8f6e16e

XCode 10 GM and Swift 4.2 fails to compile

PPBadgeViewSwift v2.2.0 still fails to build in the latest Xcode with Swift 4.2

/Users/joelaws/Workspace/kratos/Pods/PPBadgeViewSwift/PPBadgeView/swift/PPBadgeLabel.swift:72:27: 'NSAttributedStringKey' has been renamed to 'NSAttributedString.Key'
/Users/joelaws/Workspace/kratos/Pods/Foundation.NSAttributedStringKey:2:18: 'NSAttributedStringKey' was obsoleted in Swift 4.2
/Users/joelaws/Workspace/kratos/Pods/PPBadgeViewSwift/PPBadgeView/swift/UIView+PPBadgeView.swift:178:22: 'bringSubview(toFront:)' has been renamed to 'bringSubviewToFront(_:)'
/Users/joelaws/Workspace/kratos/Pods/UIKit.UIView:17:15: 'bringSubview(toFront:)' was obsoleted in Swift 4.2

有时候会影响addBadge那个superview的位置

我的情况是cell里面有一个按钮需要添加badge,结果按钮的位置出现错误查看层级打印坐标(0,0,64,35),但是我的坐标不是这个,注释掉添加badge的代码,位置显示正确
ps:我用的是frame布局

UIBarButtonItem 不显示角标

@jkpang 你好,我使用一下代码

UIBarButtonItem * navRightButton = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"形状7"] style:UIBarButtonItemStylePlain target:self action:@selector(msgmanagerBtnEvent)];
    NSLog(@"navRightButton = %@", navRightButton);
//    [navRightButton pp_addBadgeWithNumber:10];
    self.navigationItem.rightBarButtonItem = navRightButton;
    [self.navigationItem.rightBarButtonItem pp_addBadgeWithNumber:10];

就不能正确显示角标,但是使用一下代码就可以正确显示

    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setImage:[UIImage imageNamed:@"形状7"] forState:UIControlStateNormal];
    button.frame = CGRectMake(0,100,button.currentImage.size.width, button.currentImage.size.height);
    [button addTarget:self action:@selector(msgmanagerBtnEvent) forControlEvents:UIControlEventTouchDown];
    // 添加角标
    UIBarButtonItem *navRightButton = [[UIBarButtonItem alloc] initWithCustomView:button];
    self.navigationItem.rightBarButtonItem = navRightButton;
    // 添加角标
    [Manager getJiaoBiaoCount:^{
        [navLeftButton pp_addBadgeWithNumber:[USER_D integerForKey:mesCount]];
    }];

Error of some files

When i run the app and then it throws me error for the file named PPBadgeLabel.swift and it state that Constructing an object of class type 'Self' with a metatype value must use a 'required' .
Please help me to solve this problem?
I am using swift 4.0
I am using Pod 'PPBadgeViewSwift'

The badgeview doesn't show up

self.navigationItem.leftBarButtonItem = UIBarButtonItem.init(barButtonSystemItem: .add, target: self, action: nil)
self.navigationItem.leftBarButtonItem?.pp.addBadge(number: 1)
self.navigationItem.leftBarButtonItem?.pp.addDot(color: UIColor.red)
self.navigationItem.leftBarButtonItem?.pp.moveBadge(x: -5, y: 0)
I do programmatically and when i run and i don't see the badge

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.