//這裡的xywidth height要怎麼寫?
UILable *label = [[UILabel alloc] initWIthFrame:CGRectMake(x,y,width,height)] ;
[view.addSubView label];
還有對於不確定text長度的label如何設置width 啊
基於super view設置你這個label的frame.
比如你要讓這個label再父view的正中間,直接設置center屬性.
至於動態的高度,你可以通過計算string的size獲得.
NSString *yourMsg = @"your message here";
CGSize labelSize = [yourMsg sizeWithFont:[UIFont systemFontOfSize:15.0] constrainedToSize:CGSizeMake(30, MAXFLOAT) lineBreakMode:NSLineBreakByCharWrapping];// 這裡限制寬30, 不限制高度
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, labelSize.width, labelSize.height)];
label.text = yourMsg;
label.center = self.view.center;