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];




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