use yii\web\Response;
//修改content-type值
$response = \Yii::$app->response;
$response->format = Response::FORMAT_RAW;
$response->headers->add('Content-Type', 'image/png');
或者:
$response = Yii::$app->response;
$response->format = \yii\web\Response::FORMAT_JSON;
$response->data = ['message' => 'hello world'];