小编Ren*_*ade的帖子

如何在 SwiftUI 中居中裁剪图像

我是 SwiftUI 的新手。我想每个人都在这一点上。我已经做了大约 6 年的应用程序开发人员,我觉得在 StackOverflow 上问这个问题很愚蠢。但我到处看。如何在 SwiftUI 的 ImageView 中居中裁剪图像?

我知道有一个选项可以更改纵横比,但我只看到适合和填充。我只是想让 imageView 居中裁剪(android 术语)图像。有人知道吗?

image center crop ios swiftui

10
推荐指数
2
解决办法
5816
查看次数

NameError:未初始化的常量Rpush :: Gcm我正在尝试将rpush用于我的移动应用程序.但我一直收到这个错误

所以我试图使用rpush来使用这个gem的移动应用程序的推送通知:https://github.com/rpush/rpush.我正在使用sinatra框架.但我一直得到这个错误,即使我在我的文件顶部写了 - > require'rpush'.有人在红宝石中有经验可以帮助我吗?我是红宝石的新手所以请耐心等待.这是我的代码

require 'rpush'

Module Notifier

def rpush_client
app = Rpush::Gcm::App.new
app.name = "App-Name"
app.auth_key = "XXXXXXXXXXXXXXX"
app.connections = 1
app.save!
end


def notify(user_id,alert)
  rpush_client
  session = db_find_one('dbname.sessions',{user_id: user_id})
  if session.present?
    device = session['devices'].first
    token = device['device_token']
    n = Rpush::Gcm::Notification.new
    n.app = Rpush::Gcm::App.find_by_name("App-Name")
    n.registration_ids = ["token", token]
    n.data = { message: alert }
    n.save!

    Rpush.push
  end
end

end
Run Code Online (Sandbox Code Playgroud)

我知道这是一个愚蠢的问题,但厌倦了在这里寻找它.

gem notifications android push sinatra

6
推荐指数
1
解决办法
545
查看次数

如何使用java在android中绘制带有圆角矩形的二维码?

我一直致力于生成二维码并将其显示在屏幕上。现在我可以使用 Zxing 库生成它,该库为我提供了一个 BitMatrix,该 BitMatrix 返回 x 和 y 值的布尔值(如果该坐标需要为黑色或白色)。现在我可以使用以下代码成功生成并显示二维码:

String charset = "UTF-8";
Map<EncodeHintType, ErrorCorrectionLevel> hintMap = new HashMap<>();
hintMap.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);

BitMatrix matrix = new QRCodeWriter().encode(new String(url.getBytes(charset), charset), BarcodeFormat.QR_CODE, (int) context.getResources().getDimension(R.dimen.qr_square), (int) context.getResources().getDimension(R.dimen.qr_square), hintMap);


 Bitmap bitmap = Bitmap.createBitmap(matrix.getWidth(), matrix.getHeight(), Config.ARGB_8888);

 Canvas canvas = new Canvas(bitmap);
 Paint paint = new Paint();
 paint.setColor(Color.BLACK);
 for (int y = 0; y < matrix.getHeight(); y++) {
    for (int x = 0; x < matrix.getWidth(); x++) {
        if (!overlayRect.contains(x, y))
            canvas.drawPoint(x, y, paint);
    }
 } …
Run Code Online (Sandbox Code Playgroud)

java android canvas qr-code rounded-corners

5
推荐指数
1
解决办法
1564
查看次数

标签 统计

android ×2

canvas ×1

center ×1

crop ×1

gem ×1

image ×1

ios ×1

java ×1

notifications ×1

push ×1

qr-code ×1

rounded-corners ×1

sinatra ×1

swiftui ×1