【iOS】CustomBadge


CustomBadge

  • 範例, 顯示兩個 Badge, 或可以說是一個, 技巧就是把一個疊在另一個上面.
    image

    CustomBadge *customBadge1 = [CustomBadge customBadgeWithString:@"2"
                                                       withStringColor:[UIColor whiteColor]
                                                        withInsetColor:[UIColor redColor]
                                                        withBadgeFrame:YES
                                                   withBadgeFrameColor:[UIColor whiteColor]
                                                             withScale:1.0
                                                           withShining:YES];
    CustomBadge *customBadge2 = [CustomBadge customBadgeWithString:@"CustomBadge"
                                                       withStringColor:[UIColor blackColor]
                                                        withInsetColor:[UIColor greenColor]
                                                        withBadgeFrame:YES
                                                   withBadgeFrameColor:[UIColor yellowColor]
                                                             withScale:1.5
                                                           withShining:YES];
        
    [customBadge1 setFrame:CGRectMake(self.view.frame.size.width/2-customBadge1.frame.size.width/2+customBadge2.frame.size.width/2, 110, customBadge1.frame.size.width, customBadge1.frame.size.height)];
    [customBadge2 setFrame:CGRectMake(self.view.frame.size.width/2-customBadge2.frame.size.width/2, 110, customBadge2.frame.size.width, customBadge2.frame.size.height)];

        [self.view addSubview:customBadge2];
        [self.view addSubview:customBadge1];

 

Ed32. Copyright 2008 All Rights Reserved Revolution Two Church theme by Brian Gardner Converted into Blogger Template by Bloganol dot com