引言:日期选择器是日常开发常用的控件,今天突然想用canvas来写一个,与以前的实现方式有些不一样,拿出来大家看看,当做一个对比吧!
效果图:
选择中
选择后
实现步骤
绘制表格
方形构造函数
Rect.prototype.init=function(o){
for(var key in o){
this[key]=o[key];
}
}
Rect.prototype.render=function(context){
this.ctx=context;
innerRender(this);
function innerRender(obj){
var ctx=obj.ctx;
ctx.save()
ctx.beginPath();
ctx.translate(obj.x