我有關於設置UIButton框架的問題。將UIButton的框架設置爲UILabel中的特定單詞
NSString *sample = @"Demo to set display view on label in iPhone";
CGSize maximumLabelSize = CGSizeMake(55,9999);
expectedLabelSize = [sample sizeWithFont:[UIFont systemFontOfSize:20]
constrainedToSize:maximumLabelSize
lineBreakMode:UILineBreakModeWordWrap];
NSLog(@"%f",expectedLabelSize.height);
self.label = [[UILabel alloc] initWithFrame:CGRectMake(50, 50, expectedLabelSize.width, expectedLabelSize.height)];
self.label.backgroundColor = [UIColor clearColor];
self.label.numberOfLines = 0;
self.label.text = sample;
[self.label sizeToFit];
所以在下面的UIButton代碼如何設置文本框的位置,這樣只有「iPhone」這個詞是可點擊?
self.button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
self.button.frame = CGRectMake(self.label.frame.origin.x,
self.label.frame.origin.y+50,
expectedLabelSize.width,
expectedLabelSize.height);
你想讓這個按鈕自動顯示在你的標籤上嗎? –
我想單擊uilabel的iPhone文本,所以任何想法 –
啊,我想你想UIButton是文本「iPhone」在UILabel?多線標籤很難實現。最好只將文本「iPhone」放在UIButton中,而不要放在UILabel中。 – progrmr