Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

About CGRectFromString Use

In my apps, i want to use CGRectFromString to set UIButton position. my code just like that

NSString *g = @"{0,0},{100, 100}";
CGRect rect = CGRectFromString(g);
self.button1.frame = rect;

but is dosent work. anything i miss or it's apple bug ??

like image 281
Allan Avatar asked Nov 19 '25 06:11

Allan


2 Answers

You can set frame using this , its working fine. follow this link to drop your eye on CGRect

CGRect optionsFrame = {{0, 0}, {100, 100}};
self.button1.frame = optionsFrame;  

or if you really want to use CGRectFromString then please make soma changes

NSString *g = @"{{0,0},{100, 100}}"; 

I hope you understand..:)

like image 95
Rajneesh071 Avatar answered Nov 20 '25 23:11

Rajneesh071


Try like this....

NSString *g = @"{{0,0},{100, 100}}";
CGRect rect = CGRectFromString(g);
self.button1.frame = rect;
like image 25
Prasad G Avatar answered Nov 20 '25 23:11

Prasad G



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!