if you want to change the size of UIButton according to the title text then use the following function--
-(void)setDynamicSizeOfButton:(UIButton *)button andSize:(CGFloat)Size {
CGSize size = [button.titleLabel.text sizeWithAttributes:
@{NSFontAttributeName: [UIFont systemFontOfSize:Size]}];
button.frame = CGRectMake(button.frame.origin.x, button.frame.origin.y, ceilf(size.width+13),ceilf(size.height));
}
Here Size refer to the Font Size of title.
0 Comment(s)