-3
嘿,我想創建一個複選框在屏幕上,而不使用兩個不同的圖像與V和沒有。有誰知道我能做到嗎?我沒有找到它的UI類。如何使用目標創建複選框c
嘿,我想創建一個複選框在屏幕上,而不使用兩個不同的圖像與V和沒有。有誰知道我能做到嗎?我沒有找到它的UI類。如何使用目標創建複選框c
就你而言,你可以使用UIButton。因此擁有V圖像就足夠了。 (空正方形圖像的方法也被說明)
需要調用的主要方法是:
//Set the 'V' image for UIControlStateSelected and [UIImage new] for UIControlStateNormal
- (void)setImage:(UIImage *)image
forState:(UIControlState)state;
//Then, for the surrounding square box you can either use an image, OR better, use the borderWidth and borderColor property of the button's layer to achieve this effect.
//Image Method
- (void)setBackgroundImage:(UIImage *)image
forState:(UIControlState)state; // Incase you use an image then, use the same image for both UIControlStateSelected and UIControlStateNormal.
//drawing method
[checkBoxButton.layer setBorderWidth:<Enter Width in CGFloat>];
[checkBoxButton.layer setBorderColor:<Enter Width in CGColor>];
注:這裏的關鍵片將通過切換「選擇以保持所述按鈕的選擇狀態'財產。其餘的將自己照顧。
這涉及到手動創建一個UICheckbox,繪製一個2D矩形視圖和自定義視圖的檢查。所以你將不得不創建你自己的UI元素。