Заголовок UIButton и запрос выравнивания изображения

Для мелкой копии можно вместо этого использовать метод GetRange универсального класса Списка.

List oldList = new List( );
// Populate oldList...

List newList = oldList.GetRange(0, oldList.Count);

Заключенный в кавычки из: Рецепты Дженериков

28
задан Peter Hosey 3 September 2013 в 13:29
поделиться

1 ответ

Помните, что UIButton наследуется от UIView, и поэтому вы можете добавлять в него подвиды, как и в любое другое представление. В вашей ситуации вы должны создать кнопку, а затем добавить UILabel с левой стороны и UIImage справа:

// Create the button
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];

// Now load the image and create the image view
UIImage *image = [UIImage imageNamed:@"yourImage.png"];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(/*frame*/)];
[imageView setImage:image];

// Create the label and set its text
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(/*frame*/)];
[label setText:@"Your title"];

// Put it all together
[button addSubview:label];
[button addSubview:imageView];
9
ответ дан 28 November 2019 в 02:15
поделиться
Другие вопросы по тегам:

Похожие вопросы: