在UIView邊緣加徽章: UIView+MGBadgeView
允許顯示和自定義繼承自UIView每個對象上的徽章。
使用示例
這是一個簡單的例子來從代碼說明和自定義控件:
//Add buttons
UIButton *b1 = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 100, 50)];
[b1 setBackgroundColor:[UIColor grayColor]];
[[self view] addSubview:b1];
UIButton *b2 = [[UIButton alloc] initWithFrame:CGRectMake(100, 400, 100, 50)];
[b2 setBackgroundColor:[UIColor grayColor]];
[[self view] addSubview:b2];
UIButton *b3 = [[UIButton alloc] initWithFrame:CGRectMake(150, 150, 100, 50)];
[b3 setBackgroundColor:[UIColor grayColor]];
[[self view] addSubview:b3];
//Customize badges
[b1.badgeView setBadgeValue:1];
[b1.badgeView setOutlineWidth:0.0];
[b1.badgeView setPosition:MGBadgePositionBest];
[b1.badgeView setBadgeColor:[UIColor blueColor]];
[b2.badgeView setBadgeValue:2];
[b2.badgeView setOutlineWidth:1.0];
[b2.badgeView setPosition:MGBadgePositionTopRight];
[b2.badgeView setOutlineColor:[UIColor blueColor]];
[b2.badgeView setBadgeColor:[UIColor yellowColor]];
[b2.badgeView setTextColor:[UIColor blueColor]];
[b3.badgeView setBadgeValue:3];
[b3.badgeView setPosition:MGBadgePositionTopLeft];
[b3.badgeView setBadgeColor:[UIColor redColor]]; 
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!