I am looking for a way to create a CIRCULAR UIView
that is resizable and stays centered (see image). The CIRCULAR view in this example is a UIView
subclass WCSDailyGoal
.
ContainerView.m
- (void)createDailyGoalView
{
_dailyGoalView = [[WCSDailyGoalView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
_dailyGoalView.delegate = self;
_dailyGoalView.goal = 200;
_dailyGoalView.center = self.view.center;
[self.view addSubview:_dailyGoalView];
}
WCSDailyGoal.m
- (void)setGoal:(CGFloat)goal
{
CGPoint saveCenter = self.center;
CGRect newFrame = CGRectMake(self.frame.origin.x, self.frame.origin.y, goal, goal);
self.frame = newFrame;
self.layer.cornerRadius = goal / 2.0;
self.center = saveCenter;
}