Reputation: 9
I'm having a little trouble here moving a UIView up. Here are my codes.
-(void)viewWillAppear
{
if ([self.expenseToShowDetail.recurring intValue] == 1) {
//something...
} else {
[self.recurringView setHidden:YES];
self.noteUIView.layer.position = CGPointMake(160, 200);
}
}
I'm trying to hide 1 view and move the other up a bit. Am I doing something wrong here?
Thanks.
Upvotes: 1
Views: 250
Reputation: 259
please try this
[self.noteUIView setCenter:CGPointMake(160, 200)];
or
self.noteUIView.frame=self.noteUIView.frame=CGRectMake(160, 200, self.noteUIView.frame.origin.size.width, self.noteUIView.frame.origin.size.height);
Upvotes: 0
Reputation: 6557
The reason it's not working is because you've added it to viewWillAppear: method.
Add the following line to viewDidLayoutSubviews or viewDidAppear:
[self.noteUIView setCenter:CGPointMake(100, 100)];
Upvotes: 2
Reputation: 1214
View will not move once the frame is changed. we need to animate the view to move to new position. try the below code
[UIView animateWithDuration:0.0 animations:^{
CGRect rect = self.noteUIView.frame;
rect.origin.x = 160;
rect.origin.y = 200;
self.noteUIView.frame = rect;
}];
Upvotes: 1
Reputation: 6951
Do this:
self.noteUIView.center = CGPointMake(160, 200);
You were accessing self.noteUIView
's layer property, which may not have been what you were looking to do. Also, this code will not visibly move the view, it will just put it a 160, 200.
Upvotes: 3