- (IBAction)didTapOnBirthdayButton:(id)sender
{
self.hasShowPickerView = !self.hasShowPickerView
if (self.hasShowPickerView) {
CGRect birthdayButtonFrame = self.birthdayButton.frame
birthdayButtonFrame = [self.view convertRect:birthdayButtonFrame fromView:self.birthdayButton.superview]
CGFloat birthdayButtonYOffset = birthdayButtonFrame.origin.y + birthdayButtonFrame.size.height
CGFloat gap = birthdayButtonYOffset - (self.view.frame.size.height - self.pickerContainerView.frame.size.height)
CGRect bounds = self.view.bounds
if (gap >0) {
bounds.origin.y = gap
} else {
gap = 0
}
[self replacePickerContainerViewTopConstraintWithConstant:birthdayButtonYOffset]
[UIView animateWithDuration:0.25 animations:^{
self.view.bounds = bounds
[self.view layoutIfNeeded]
}]
} else {
[self replacePickerContainerViewTopConstraintWithConstant:self.view.frame.size.height]
CGRect bounds = self.view.bounds
bounds.origin.y = 0
[UIView animateWithDuration:0.25 animations:^{
self.view.bounds = bounds
[self.view layoutIfNeeded]
}]
}
}
上述代码中的[self.view layoutIfNeed]去掉也是没问题的。可能比较费解的是根view.bounds.origin.y的上移gap的计算以及top constraint的constant值的计算,关键实在真正理解view的frame和bounds的意义。
选择File-->CAM,在对话框中选择丝印层,点Edit-->Layers,然后将top和silkscrenen top(底层就是bottom和silkscreen bottom)添加到右边的Selected框中,然后分别选中这两项,勾选Ref.Des选项,点OK即可。欢迎分享,转载请注明来源:内存溢出
评论列表(0条)