Note that there are some explanatory texts on larger screens.

plurals
  1. POProblems to set BadgeLabel to be dynamically
    primarykey
    data
    text
    <p>I have tow buttons and on the left side of every button is a badge label but i want that the size of these badge label dynamic how can i do this at the moment is something like that <img src="https://i.stack.imgur.com/wpCuC.png" alt="when i start the app"></p> <p>When i start the app</p> <p>but when i scroll the hole cell up then it is how it should be <img src="https://i.stack.imgur.com/iApjH.png" alt="how it should be "></p> <p>Using Iphone sdk 6.0:</p> <pre><code>#import &lt;QuartzCore/QuartzCore.h&gt; #import "JSMBadgeLabel.h" @interface JSMBadgeLabel () -(void) setup; @end @implementation JSMBadgeLabel @synthesize targetUIView = _targetUIView; -(void) setup{ self.layer.cornerRadius = self.font.pointSize *0.8; } -(void)awakeFromNib { [self setup]; } -(void)setText:(NSString *)text{ [super setText:text]; CGSize size = [text sizeWithFont:self.font]; self.frame = CGRectMake(self.frame.origin.x ,self.frame.origin.y,size.width + self.font.pointSize *0.8,size.height); CGRect badgeFrame = self.frame; CGRect targetFrame = self.targetUIView.frame; self.frame = CGRectMake(targetFrame.origin.x+targetFrame.size.width- badgeFrame.size.width/2,targetFrame.origin.y-badgeFrame.size.height/2,badgeFrame.size.width,badgeFrame.size.height);}@end -(void) updateAsBadge:(NSString*)newText { self.text = newText; [self sizeToFit]; const int padding = 1; self.frame = CGRectMake(self.superview.bounds.size.width - self.bounds.size.width-padding, padding, self.bounds.size.width, self.bounds.size.height); } </code></pre> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload