I have implemented a custom button as follows.
UIButton *mainBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[mainBtn setTitle:@"Meeting" forState:UIControlStateNormal];
[mainBtn setFrame:CGRectMake(80, 7, 72, 35)];
[mainBtn setBackgroundImage:[UIImage imageNamed:@"buttonActive.png"] forState:UIControlStateNormal];
mainBtn.contentEdgeInsets = UIEdgeInsetsMake(18, 5, 18, 10);
[mainBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
Here button title going to be dynamic one. So now I need to change the button width according to the length of the title dynamicaly. For that CGRectMake with given width wont work. Can some one help me to do that.
Just use the following code,