在View中添加一个UIToolBar,其中代码如下:
//定义UIToolBar m_pToolBar= [[UIToolbaralloc]initWithFrame:CGRectMake(0.0,self.view.frame.size.height-m_pActionButton.frame.size.height- 44.0,self.view.frame.size.width,44.0)]; [m_pToolBar setBarStyle:UIBarStyleBlackOpaque]; m_pToolBar.autoresizingMask=UIViewAutoresizingFlexib //向uitoolbar添加控件 m_pTextField=[[UITextFieldalloc]initWithFrame:CGRectMake(12.0,7.0,264.0,31.0)]; m_pTextField.delegate= self; [m_pTextField setBorderStyle:UITextBorderStyleRounded [m_pTextField setFont:[UIFont fontWithName:@"Helvetica" size:16.0]]; m_pButtonAdd= [UIButton buttonWithType:UIButtonTypeCustom]; [m_pButtonAdd setFrame:CGRectMake(286.0,8.0,29.0,29.0)]; [m_pButtonAdd addTarget:selfaction:@selector(addOpinion)forControlEvents:UIControlEventTouchUpIns [m_pButtonAdd setImage:[UIImage imageNamed:@"button_plus"]forState:UIControlStateNormal]; UIBarButtonItem *mBarButtonItemTextField =[[UIBarButtonItemalloc]initWithCustomView:m_pTextField]; UIBarButtonItem *mBarButtonItemButtonAdd =[[UIBarButtonItemalloc]initWithCustomView:m_pButtonAdd]; [m_pToolBarsetItems:[NSArrayarrayWithObjects:mBarButtonItemTextField,mBarButtonItemButtonAdd,nil]]; [mBarButtonItemTextFieldrelease]; [mBarButtonItemButtonAddrelease]; |