//
// diytextview.h
// textreturndemo
//// created by 低調&愛 on 16/3/7.
// diytextview.h檔案(自定義.h檔案)
#define hotspot_statusbar_height 20
#define sys_statusbar_height 20
//獲取螢幕寬度、高度
#define screen_width ([uiscreen mainscreen].bounds.size.width)
#define screen_height ([uiscreen mainscreen].bounds.size.height)
//螢幕適配
#define width ([uiscreen mainscreen].bounds.size.width / 320)
#define height ([uiscreen mainscreen].bounds.size.height / (568+is_hotspot_connected))
//字型顏色
#define text_dark_color [uicolor colorwithred:0.26 green:0.29 blue:0.33 alpha:1]
#define text_light_color [uicolor colorwithred:0.66 green:0.67 blue:0.69 alpha:1]
#define placeholder @"請填寫您的訂單備註"
#define img @"downkeybord"
@inte***ce diytextview : uitextview
@property (nonatomic,strong)uibutton *donebutton;
//新增收回鍵盤按鈕
- (uibutton *)donebuttonwithsel:(sel)sel andobject:(id)object;
@end //
// diytextview.m
// textreturndemo
//// created by 低調&愛 on 16/3/7.
//// diytextview.m檔案(自定義.m檔案)
#import "diytextview.h"
@implementation diytextview
/*// only override drawrect: if you perform custom drawing.
// an empty implementation adversely affects performance during animation.
- (void)drawrect:(cgrect)rect
*/- (id)initwithframe:(cgrect)frame
return self;
}- (uibutton *)donebuttonwithsel:(sel)sel andobject:(id)object
return_donebutton;
}//如果有字數限制
- (bool)textview:(uitextview *)textview shouldchangetextinrange:(nsrange)range replacementtext:(nsstring *)text
//nsstring *strs = [textfield.text stringbydeletingpathextension];
return yes;
}//收回鍵盤
- (void)surebtnclick
@end
//// viewcontroller.m
// textreturndemo
//// created by 低調&愛 on 16/3/7.
//// viewcontroller.m(在controller中使用)
#import "viewcontroller.h"#import "diytextview.h"
//#import "toorview.h"
//字型顏色
#define text_dark_color [uicolor colorwithred:0.26 green:0.29 blue:0.33 alpha:1]
#define text_light_color [uicolor colorwithred:0.66 green:0.67 blue:0.69 alpha:1]
@inte***ce viewcontroller ()@property (nonatomic,strong)diytextview *toorview;
@property (nonatomic,strong)nsstring *remark;
@end
@implementation viewcontroller
- (void)viewdidload
- (diytextview *)toorviewlayout
[self.viewaddsubview:_toorview];
}return_toorview;
}-(void)textviewdidbeginediting:(uitextview *)textview
}-(void)textviewdidendediting:(uitextview *)textview
}- (void)didreceivememorywarning
@end
自定義控制項textview
自定義控制項名稱 public class cheyouquanlinearlayout extends viewgroup public cheyouquanlinearlayout context context,int horizontalspacing,int verticalspacing...
自定義閃爍Textview
一直感覺自定義view是乙個比較難的點,但是要成為乙個合格的android開發者,自定義view又是必經之路。今天我就帶大家寫乙個簡單的自定義textview。在自定義view之前先看一下簡單知識點。1.view的測量。view的測量模式有三種,精確模式 exactly 如控制項具體寬高的大小 最大...
Android 自定義TextView字型!
兩種方法 方法一 在assets目錄下新建目錄fonts,然後存放自己的字型庫,我這裡是微軟雅黑weiruanyahei.ttf。textview tv typeface tf2 typeface.createfromasset getassets fonts weiruanyahei.ttf tv...