فهرست منبع

Status Label: resize correctly when content is changed

Felix Paul Kühne 12 سال پیش
والد
کامیت
bd0d4a487f
1فایلهای تغییر یافته به همراه9 افزوده شده و 0 حذف شده
  1. 9 0
      AspenProject/VLCStatusLabel.m

+ 9 - 0
AspenProject/VLCStatusLabel.m

@@ -13,6 +13,15 @@
 - (void)showStatusMessage:(NSString *)message
 {
     self.text = message;
+
+    /* layout and horizontal center in super view */
+    [self sizeToFit];
+    CGRect selfFrame = self.frame;
+    CGRect parentFrame = [self window].bounds;
+    selfFrame.size.width += 15.; // take extra width into account for our custom drawing
+    selfFrame.origin.x = (parentFrame.size.width - selfFrame.size.width) / 2.;
+    [self setFrame:selfFrame];
+
     [self setNeedsDisplay];
     [self _toggleVisibility:NO];