Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to make a Round UIView with selected Daimeter programatically in iOS

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 289
    Comment on it
    1. Create UIView as UIView *myroundView; or watever name suits u...
    1. Allocate it itz memory as well as its frame & its diameter as-

      myroundView = [[UIView alloc]initWithFrame:CGRectMake(40, 18, 15, 15)];
      [self setRoundedView:myroundView toDiameter:16];
    2. Create the following function--

    (void)setRoundedView:(UIView *)roundedView toDiameter:(float)newSize
    {
        CGPoint saveCenter = roundedView.center;
        CGRect newFrame = CGRectMake(roundedView.frame.origin.x, roundedView.frame.origin.y, newSize, newSize);
        roundedView.frame = newFrame;
        roundedView.layer.cornerRadius = newSize / 2.0;
        roundedView.center = saveCenter;
    }
    1. Now in viewDidLoad add background-color to check its appearance as-
    myroundView.backgroundColor = [UIColor lightGrayColor];
    1. Now run the code & check your Rounded UIView,Thanks for reading...

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: