我已经创建了新的Yii2基础项目并希望深入挖掘.
登录页面上有一个用户名字段:

我想将标签'Username'更改为自定义标签,例如'My superb label'.我已阅读手册:http: //www.yiiframework.com/doc-2.0/yii-widgets-activefield.html
稍微调查一下后,我得到了下一个结果:

我只更改了模板并更改了布局:
<?= $form->field($model, 'username', [
"template" => "<label> My superb label </label>\n{input}\n{hint}\n{error}"
])?>
Run Code Online (Sandbox Code Playgroud)
如何以正确的方式更改标签的文本?什么是最佳做法?
有两种drawRect方法:
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
// do drawing here
CGContextRestoreGState(context);
}
Run Code Online (Sandbox Code Playgroud)
和
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
UIGraphicsPushContext(context);
// do drawing here
UIGraphicsPopContext();
}
Run Code Online (Sandbox Code Playgroud)
UIGraphicsPushContext/UIGraphicsPopContext来自UIKit, 而CGContextSaveGState/CGContextRestoreGState来自CoreGraphics.
问题:这些方法有什么区别?哪一个更好用?是否有一些证明一种方法比其他方法更好的例子,反之亦然?