anotherViewController.myLabel = [NSString stringWithFormat:@"Telephone %@",
anotherViewController.title];
这是一个previus标签的声明,但我不知道如何为按钮做这个... 数据数组以此格式定位
phoneNumbers = [[NSArray alloc] initWithObjects:@"6940313388", @"4045434218", nil ];
self.phoneNumbers =phoneNumbers;
然后只需添加标签
theLabel.text = myLabel;
其中mylabel是NSString
请帮助我一直试图解决这个问题很长一段时间......
答案 0 :(得分:0)
这是我用来制作按钮的代码。然后将按钮添加到视图中!
编辑:您可以将setTitle:part的一部分更改为您希望按钮显示为标题的任何字符串。
//create the button
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
//sets its size
[button setFrame:CGRectMake(10, 10, 300, 50)];
//set title, font size and font color
[button setTitle:@"Sign Up" forState:UIControlStateNormal];
[button setFont:[button.font fontWithSize:22]];
[button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[button setBackgroundImage:[UIImage imageNamed:@"green_btn_bg.png"] forState:UIControlStateNormal];
//set action of the button
[button addTarget:self action:@selector(signUp:)
forControlEvents:UIControlEventTouchUpInside];