iOS Question Obj C Class and #IF OBJC / An attempt at ViewBadger functionality for iOS

Discussion in 'iOS Questions' started by henrywood, Apr 24, 2015.

  1. henrywood

    henrywood Active Member Licensed User

    In the Android version of my app, I use ViewBadger to put a badge on buttons.
    Now I try to do the same in iOS.
    I found this Objective C Class: http://latest.docs.nimbuskit.info/NIBadgeView.html

    My question is: Can I use that class by importing the NimbusBadge.h from within an #IF OBJC block in B4i, define a wrapper in Objective C to set a badge on a view and then write a B4i Sub that wraps the Objective C wrapper method ?

    Something like this:

    Code:
    #IF OBJC
    #import "NimbusBadge.h"

    - (void) setBadgeViewInternal:(NSString*)txt :(UIColor*)bgColor :(UIView*)viewButton
    {
    NIBadgeView* badgeView = [[NIBadgeView alloc] initWithFrame:CGRectZero];
    badgeView.text = txt;
    badgeView.tintColor = bgColor;
    [badgeView sizeToFit];
    [viewButton addSubview:badgeView];
    }

    #END IF

    Sub setBadgeView(txt As String, bgColor As Color, v As View)

    Dim no As NativeObject = Me
    no.RunMethod(
    "setBadgeViewInternal:::"Array As Object(txt, no.ColorToUIColor(bgColor), v))

    End Sub
    And calling the B4i sub:

    Code:
    Dim btn As Button
    btn.Text = 
    "Click Me"
    setBadgeView(
    "7"Colors.Blue, btn)
    If this is possible, where do I place any .h and .m files of NimbusBadge so that they are included in my project ?
     
    Last edited: Apr 24, 2015
  2. Erel

    Erel Administrator Staff Member Licensed User

    You will need to put the .h and .a (compiled object) files in the server libs folder.

    You will then need to modify one of the libraries xml file and add a DependsOn node with the new library.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice