我想添加一個customBadge作爲一個UIButton的子視圖 -添加子視圖的UIButton
這是我到目前爲止的代碼 -
//msg count initiaition
//CustomBadge *customBadge1 = [CustomBadge customBadgeWithString:@"2"];
CustomBadge *customBadge1 = [CustomBadge customBadgeWithString:@"2"
withStringColor:[UIColor whiteColor]
withInsetColor:[UIColor redColor]
withBadgeFrame:YES
withBadgeFrameColor:[UIColor redColor]
withScale:2.0
withShining:YES];
// Set Position of Badge 1
[customBadge1 setFrame:CGRectMake(self.view.frame.size.width/2-customBadge1.frame.size.width/2+_MsgHeadBtn.frame.size.width/2, 110, customBadge1.frame.size.width, customBadge1.frame.size.height)];
//add badge to view
[_MsgHeadBtn addSubview:customBadge1];
按鈕我試圖加子視圖爲_MsgHeadBtn,這是以下屏幕截圖頂部LH上的電子郵件圖標。 我試圖讓自定義徽章在電子郵件圖標的右側顯示輕微的位置 - 但最終會在截圖中顯示結果!
誰能提供任何意見,以我要去哪裏錯了!?
我會說:'[customBadge1 SETFRAME:CGRectMake(_MsgHeadBtn.frame .size.width,0,customBadge1.frame.size.width,customBadge1.frame.size.height)];' – sergio
@sergio:感謝您的信息。我只是修改了我的答案:) –
作品 - 不錯的一個! – Dancer