所以我想在特定条件(消息传递应用程序)的情况下扩展uiview。我使用此代码扩展和收缩视图(并在图片中移动适当的按钮以在更新的扩展区域中):
-(void)transformKeyBoardViewForPictureMessage:(int)heightToAdd
{
//Resize whole view
CGRect oldFrame = self.frame;
self.frame = CGRectMake(oldFrame.origin.x, oldFrame.origin.y, oldFrame.size.width, oldFrame.size.height + heightToAdd);
//move up the preview imageview
CGRect previewFrame = self.picPreview.frame;
self.picPreview.frame = CGRectMake(previewFrame.origin.x, previewFrame.origin.y + heightToAdd, previewFrame.size.width, previewFrame.size.height);
//move up the remove pic button
self.removePicButton.frame = CGRectMake(removeFrame.origin.x, removeFrame.origin.y + heightToAdd, removeFrame.size.width, removeFrame.size.height);
self.backgroundColor = [UIColor lightGrayColor];
}
这种方法的工作原理是removePicButton和picPreview向上移动,我可以看到它们;但是我无法触摸removePicButton以及“扩展帧”的新区域中的任何元素,此外背景颜色仅在视图的旧帧内重置而不是新的帧部分(仅具有清晰的背景)。