---------------————————自定義uiview——————————————————————————————
//重寫
- (void
)drawrect:(
cgrect
)rect
//生成乙個三角形
uibezierpath
*path = [
uibezierpath
bezierpath];
[path
movetopoint
:cgpointmake(20
, 20
)];
[path
addlinetopoint
:cgpointmake
(self
.frame
.size
.width
- 40
, 20
)];
[path
addlinetopoint
:cgpointmake
(self
.frame
.size
.width/ 2
, self
.frame
.size
.height
- 20
)];
// 最後的閉合線是可以通過呼叫
closepath
方法來自動生成的,也可以呼叫
-addlinetopoint:
方法來新增
// [path addlinetopoint:cgpointmake(20, 20)];
[path
closepath];
// 設定線寬
path.
linewidth
= 1.5;
// 設定填充顏色
uicolor
*fillcolor = [
uicolor
greencolor];
[fillcolor
set];
[path
fill];
// 設定畫筆顏色
uicolor
*strokecolor = [
uicolor
bluecolor];
[strokecolor
set];
// 根據我們設定的各個點連線
[path
stroke];
//自定義顯示部分
uibezierpath
*path2 = [
uibezierpath
bezierpath];
[path2
movetopoint
:cgpointmake(40
, 40
)];
[path2
addlinetopoint
:cgpointmake
(self
.frame
.size
.width
- 100
, 40
)];
[path2
addlinetopoint
:cgpointmake
(self
.frame
.size
.width/ 2
, self
.frame
.size
.height
- 60
)];
cashapelayer
*shapelayer = [
cashapelayer
layer];
shapelayer.
frame
= self
.bounds;
shapelayer.
path
=path2.
cgpath;
shapelayer.
fillcolor
= [uicolor
whitecolor
].cgcolor;
shapelayer.
backgroundcolor
= [uicolor
clearcolor
].cgcolor;
//新增遮罩,除上面設定的路徑,其餘部分都不顯示 [
self
.layer
setmask
:shapelayer];
Android自定義控制項之自定義View 二
效果如下圖 1 自定義ringview繼承view新增其構造方法並建立畫筆 public class ringview extends view protected boolean isrunning false public ringview context context public ring...
自定義View 聚焦動畫控制項
我盡量不打錯別字,用詞準確,不造成閱讀障礙。這個自定義view是很簡單的乙個,效果是在拍攝時的對焦動畫,在自定義su ceview中使用這個控制項就好了。效果如下 初始化 private void init private void setmaincolor private void reset o...
WPF DataGrid控制項的自定義資料顯示格式
wpf的datagrid控制項是在wpftoolkit增加的,而wpf 4.0直接包含了這個控制項。在繫結資料來源時,日期時間格式的顯示可以用標準的字串格式化方式。比如,我想將datetime型別的列顯示為 yyyy mm dd hh mm ss 格式,在繫結屬性裡增加 stringformat 為...