ios中自定义控件

1,自定义Button

UIButton *subjectButton = [UIButtonbuttonWithType:UIButtonTypeCustom];//此处可以修改button类型

        [subjectButtonsetFrame:CGRectMake(109,604, 132, 44)];

        [subjectButton setTitle:@""forState:UIControlStateNormal];

        [meetingaddSubview:subjectButton];

[subjectButton addTarget:selfaction:@selector(enterSubject:)forControlEvents:UIControlEventTouchUpInside];

- (void)enterSubject:(id)sender

{

    NSLog(@"进入会议详情页");

}


//摘录网上资源

  //义按钮标题

         [sampleButton setTitle:@"Button Title" forState:UIControlStateNormal];

        

    //义按钮标题字体格式

         [sampleButton.titleLabel setFont:[UIFont boldSystemFontOfSize:20]];

        

    //义按钮背景图片,redButton.png经存在,拖放添加图片文件到image项目文件夹中

         [sampleButton setBackgroundImage:[[UIImage imageNamed:@"redButton.png"]stretchableImageWithLeftCapWidth:0.0 topCapHeight:0.0] forState:UIControlStateNormal];




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章