Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Classes/CustomBadge.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@
+ (CustomBadge*) customBadgeWithString:(NSString *)badgeString withScale:(CGFloat)scale withStyle:(BadgeStyle*)style;

- (void) autoBadgeSizeWithString:(NSString *)badgeString;
- (void) changeXibViewToBadgeWithString:(NSString*)badgeString withScale:(CGFloat)scale;

@end
13 changes: 13 additions & 0 deletions Classes/CustomBadge.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,19 @@ - (id) initWithString:(NSString *)badgeString withScale:(CGFloat)scale withStyle
return self;
}

// Use this method if you want to change UIView from Xib to BadgeView.
- (void) changeXibViewToBadgeWithString:(NSString*)badgeString withScale:(CGFloat)scale{

self.contentScaleFactor = [[UIScreen mainScreen] scale];
self.backgroundColor = [UIColor clearColor];
self.badgeText = badgeString;
self.badgeStyle = [BadgeStyle defaultStyle];
self.badgeCornerRoundness = 0.4;
self.badgeScaleFactor = scale;
[self autoBadgeSizeWithString:badgeString];

}


// Use this method if you want to change the badge text after the first rendering
- (void) autoBadgeSizeWithString:(NSString *)badgeString
Expand Down
3 changes: 2 additions & 1 deletion Classes/CustomBadgeViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@


#import <UIKit/UIKit.h>

#import "CustomBadge.h"
@interface CustomBadgeViewController : UIViewController {

}
@property (weak, nonatomic) IBOutlet CustomBadge *badgeViewFromXIB;

@end

3 changes: 2 additions & 1 deletion Classes/CustomBadgeViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ of this software and associated documentation files (the "Software"), to deal
*/

#import "CustomBadgeViewController.h"
#import "CustomBadge.h"

@implementation CustomBadgeViewController

Expand Down Expand Up @@ -119,6 +118,8 @@ - (void) viewDidLoad
[self.view addSubview:badge];
}

[_badgeViewFromXIB changeXibViewToBadgeWithString:@"9" withScale:1.0];

}


Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0630"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1D6058900D05DD3D006BFB54"
BuildableName = "CustomBadge.app"
BlueprintName = "CustomBadge"
ReferencedContainer = "container:CustomBadge.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1D6058900D05DD3D006BFB54"
BuildableName = "CustomBadge.app"
BlueprintName = "CustomBadge"
ReferencedContainer = "container:CustomBadge.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1D6058900D05DD3D006BFB54"
BuildableName = "CustomBadge.app"
BlueprintName = "CustomBadge"
ReferencedContainer = "container:CustomBadge.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1D6058900D05DD3D006BFB54"
BuildableName = "CustomBadge.app"
BlueprintName = "CustomBadge"
ReferencedContainer = "container:CustomBadge.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>CustomBadge.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>1D6058900D05DD3D006BFB54</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
Loading