Skip to content

Instantly share code, notes, and snippets.

@lamprosg
Created March 26, 2013 07:31
Show Gist options
  • Select an option

  • Save lamprosg/5243702 to your computer and use it in GitHub Desktop.

Select an option

Save lamprosg/5243702 to your computer and use it in GitHub Desktop.
(iOS) Example stretching an image
UIView *tmpView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetMaxX(self.tableView.bounds), 265)];
NSString *lbl = L(addPhoto);
CGFloat labelwidth = [lbl sizeWithFont:kAddPhotoBtnFont].width;
FormButtonElement *addPhotoBtn = [[FormButtonElement alloc] initWithFrame:CGRectMake(kLeftRightPadding, 0, labelwidth+kLeftRightPadding*4, 30)];
[addPhotoBtn setTitle:L(addPhoto) forState:UIControlStateNormal];
addPhotoBtn.titleLabel.font = kAddPhotoBtnFont;
//Resize background image according to the string
UIImage *button = [[UIImage imageNamed:@"addPhoto.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0.0, 20.0, 30.0, 20.0)];
[addPhotoBtn setButtonImageStyle:button];
addPhotoBtn.titleEdgeInsets = UIEdgeInsetsMake(0.0, 20.0, 0.0, 0.0);
[addPhotoBtn addTarget:self action:@selector(addPhotoBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
[tmpView addSubview:addPhotoBtn];
imageNumberLabel = [[UILabel alloc] initWithFrame:CGRectMake(addPhotoBtn.frame.size.width + 20, 0, CGRectGetMaxX(self.tableView.bounds), 30)];
[imageNumberLabel setBackgroundColor:[UIColor clearColor]];
imageNumberLabel.textColor = kCellTextLabelColorNormal;
[tmpView addSubview:imageNumberLabel];
UILabel *descriptionLabel = [[UILabel alloc] initWithFrame:CGRectMake(kLeftRightPadding, addPhotoBtn.frame.size.height, CGRectGetMaxX(self.tableView.bounds), 40)];
[descriptionLabel setText:L(description)];
[descriptionLabel setBackgroundColor:[UIColor clearColor]];
descriptionLabel.textColor = kCellTextLabelColorNormal;
descriptionLabel.font = kDescriptionLabel;
[tmpView addSubview:descriptionLabel];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment