Giter Site home page Giter Site logo

jsbadgeview's Introduction

JSBadgeView

CI Status Version License Platform

Customizable UIKit badge view like the one on applications in the iOS springboard. Very optimized for performance: drawn entirely using CoreGraphics.

Snapshoot:

Usage

  • Clone the repository:
$ git clone [email protected]:JaviSoto/JSBadgeView.git
  • Check out the sample project.

  • Drag the JSBadgeView folder into your project.

  • Include the header file:

#import "JSBadgeView.h"
  • Create a JSBadgeView and attach it to a view at the position you like. Example:
JSBadgeView *badgeView = [[JSBadgeView alloc] initWithParentView:rectangle alignment:JSBadgeViewAlignmentTopRight];
badgeView.badgeText = @"3";
  • Check the header file for all the things you can customize.
  • Add pod 'JSBadgeView' to your Podfile.
  • You're done!

UIAppearance

  • You can customize all JSBadgeViews in your application, or the ones that are subviews of a specific type of view, using UIAppearance. Example:
[[JSBadgeView appearance] setBadgeBackgroundColor:UIColor.blackColor];
[[JSBadgeView appearance] setBadgeAlignment:JSBadgeViewAlignmentTopRight];

Compatibility

  • Supports ARC. If you want to use it in a project without ARC, mark JSBadgeView.m with the linker flag -fobjc-arc.
  • Compatible with iOS7.0+.

MIT License

Copyright 2013 Javier Soto ([email protected])

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

jsbadgeview's People

Contributors

autresphere avatar bitdeli-chef avatar datwelk avatar frowing avatar hiromichiyamada avatar igor-palaguta avatar javisoto avatar joanromano avatar kamilpowalowski avatar masgharneya avatar psli avatar seanoshea avatar vvit avatar yanzhiwei147 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  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

jsbadgeview's Issues

Address warnings under iOS7/XCODE 5

Looks like there are a number of warnings about deprecated function calls with XCODE 5 and iOS7 as a target. As a fanatic of 'no warning' builds, I'd love if those issues could be addressed.

Thanks for contributing this to the community!

iOS8 support?

Is the project still active? Any plan on supporting iOS8?

Question: badgeview on UIBarButtonItem

Hello I have been looking at this for some time now and haven't quite found a solution. I am looking to put a badge view on a Bar Button Item and am getting the warning (it force closes) "Incompatible pointer types sending 'UIBarButtonItem *' to parameter of type 'UIView *'"

I was hoping someone with more experience than I has either dealt with this prior or has found a solution.

Many thanks for your time!

Swift 3 Support

Is there a branch that I can point CocoaPods to that will support Swift 3.0?

Is there any way to see the text as transparent?

Hello Nacho!
Is there any easy way to see the text as transparent?
I mean, if I use:
_messagesCountBadgeView.badgeTextColor=[UIColor clearColor];
What I see is just a circle painted with badgeBackgroundColor, which makes sense.
I guess something like a mask operation must be done, not sure.
Any idea or suggestion?

Badge prevent touches to underlying view?

Great work! I've been using in my app, but I notice that the badge prevents the underlying view from receiving touches. This really only becomes an issue when placing the badge partially over a small toolbar item. For now, I've worked around it by adding the following code to JSBadgeView and I set the same action on both the badge and toolbar item:

id _target;
SEL _action;

- (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
{
    if(_target != nil && _action != nil) {
        [_target performSelector:_action withObject:nil];
    }
}

- (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents;
{
    _target = target;
    _action = action;
}

Project Structure

Hi there,

Was wondering whether you'd be open to restructuring the repo for this library to be more along the lines of a pod lib create JSBadgeView ala https://guides.cocoapods.org/making/using-pod-lib-create.html? I just included this repo in a pull request for a feature at work and it was pointed out that importing the pod means that the same project appeared in the project too. I believe using pod lib create JSBadgeView wouldn't result in the sample project appearing.

I'd be happy to contribute to this in much the same manner as AFNetworking/AFAmazonS3Manager#88 if you'd be open to the restructuring of the library.

Cheers,

Sean

Build error in Xcode 7.3 using JSBadgeView from CocoaPods

Hi, I'm getting an odd build error when adding JSBadgeView via CocoaPods. I thought it might be a config issue with my project, so I created a brand new project and nothing else but installed JSBadgeView via CocoaPods and still same issue. If ye GitHub gods favor me today, the screenshot of my error might be attached here :-). I have not seen this with any other pod I've added. Any ideas? Thanks!
screen shot 2016-04-01 at 2 25 41 pm

Add badgeSize method to public API

The following properties should be exposed to public API and be customizable using Appeareance.

JSBadgeViewShadowRadius
JSBadgeViewHeight
JSBadgeViewTextSideMargin
JSBadgeViewCornerRadius

I will be happy to do a pull request when I have more time.

Regards,

New CocoaPods version

I think it´s time to do a new tag for Cocoapods, as in the newest tag there´s one warning when using arm64.

CollectionView Item issue

Hello,

I added badge in the Collection View item.
It works fine but Some part of badge hides by image view in the cell.
How can I solve that?

Thank you,

setBadgeTextFont should update layout

as font affects size of badge, [self setNeedsLayout] should be called inside setBadgeTextFont, probably not just this method should initiate setNeedsLayout

Badge does not appear unless I tap on barButtonItem

Hello,

I have a QRCode Scanner.. when I scan the code and tap on 'add button' I set the badge of my BarButtonItem, see:

JSBadgeView *badgeView = [[JSBadgeView alloc] initWithParentView:self.productsButtonItem alignment:JSBadgeViewAlignmentTopRight];
badgeView.badgeText = @"3";

But the badge does not apper unless I tap on my barButtonItem..

I have to do something more?

Thanks

Unable to apply a transform

Would be great if we could apply a transform mainly to change the scale. For now, the drawRect does not cope well with such transform.

Badge does not show on simulator iOS 7.1

Hello,

I use your library to add some badge over button in my app. When I run it on device or simulator on iOS8.3 it works, I see the badge but when I put the app on the simulator with device on iOS7.1, the badge does not show itself.
Did I miss something about the compatibility of your library ?

BadgeAlignment is always JSBadgeViewAlignmentTopRight

The BadgeAlignment property is always JSBadgeViewAlignmentTopRight.

This is because + (void)applyCommonStyle sets
badgeViewAppearanceProxy.badgeAlignment = JSBadgeViewAlignmentTopRight;

so the calls to
JSBadgeView *badgeViewAppearanceProxy = JSBadgeView.appearance;

in + (void)applyIOS7Style and + (void)applyLegacyStyle always gets set to JSBadgeViewAlignmentTopRight.

This can be fixed by commenting out/removing:
badgeViewAppearanceProxy.badgeAlignment = JSBadgeViewAlignmentTopRight;

in + (void)applyCommonStyle

badge is clipped.

JSBadgeView's parent view is UIImageView,and it's property masksToBounds is set to YES.The top right badgeText is clipped.How to resolve this issue?

64 bit compatibility

in class:
JSBadgeView

method:
layoutSubviews

NSAssert(NO, @"Unimplemented JSBadgeAligment type %d", self.badgeAlignment);

should change

NSAssert(NO, @"Unimplemented JSBadgeAligment type %lu", (unsigned long)self.badgeAlignment);

for suppressing compiling warning

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.