如何在SwiftUI中为图片设置固定大小?目前我的图片真的很大
目前,我具有以下结构:
// @route POST api/auth
// @desc Authenticate user and get token
// @access Public
router.post(
"/",
[
check("email", "Please include a valid email").isEmail(),
check("password", "Please is required").exists()
],
async (req, res) => {
const errors = validationResult(req);
// send back any errors
if (!errors.isEmpty()) {
return res.status(400).json({
errors: errors.array()
});
}
const { email, password } = req.body;
try {
// check if user exists, send error if so
let user = await User.findOne({ email });
if (!user) {
return res
.status(400)
.json({ errors: [{ msg: "Invalid credentials" }] });
}
const isMatch = await bcrypt.compare(password, user.password);
if (!isMatch) {
return res
.status(400)
.json({ errors: [{ msg: "Invalid credentials" }] });
}
// return jsonwebtoken so that way they're logged in right
// away, without having to log in after registering
const payload = {
user: {
id: user.id
}
};
jwt.sign(
payload,
config.get("jwtSecret"),
{
expiresIn: process.env.PORT ? 3600 : 36000
},
(err, token) => {
if (err) throw err;
console.log(token); // prints token!
return res.json({ token });
}
);
} catch (err) {
console.log(err);
res.status(500).send("Server error");
}
}
);
答案 0 :(得分:3)
一种方法是通过
profileImage.resizable().frame(width: 50, height: 50)
答案 1 :(得分:1)
There are multiple ways to set fixed size to Image
1) Image("yourImage").frame(width: 25, height: 25, alignment: .center)
2) Image("yourImage").resizable().frame(width: 25, height: 25, alignment: .center)
3) Image("yourImage").frame(width: 25, height: 25, alignment: .center).clipped()
Attached the screenshots for all.
[![image1][1]][1]
[![image2][2]][2]
[![image3][3]][3]
[1]: https://i.stack.imgur.com/242QK.png
[2]: https://i.stack.imgur.com/n6dWZ.png
[3]: https://i.stack.imgur.com/I0VC0.png