我想知道是否可以制作状态栏显示文本,而不是在状态栏中显示图标。 虽然我不认为这会在我的代码中提供很多帮助:
let icon = NSImage(named: NSImage.Name(rawValue: "statusIcon"))
icon?.isTemplate = true // best for dark mode
statusItem.image = icon
statusItem.menu = statusMenu
目前正在显示图片,但如何在不制作包含文字的图片的情况下显示图片?
答案 0 :(得分:3)
Swift 4.2
using UnityEngine;
public class PlayerController : MonoBehaviour
{
private float speed = 3f;
private Animator anim;
private SpriteRenderer sr;
void Awake()
{
anim = GetComponent<Animator>();
sr = GetComponent<SpriteRenderer>();
}
void Update()
{
Move();
}
void Move()
{
float h = Input.GetAxisRaw("Horizontal");
transform.Translate(Vector2.right * (h * speed * Time.deltaTime));
anim.SetBool("Walk", h != 0f);
if (anim.GetBool("Walk"))
Flip(h > 0f);
}
void Flip(bool facingRight)
{
sr.flipX = !facingRight;
}
}
答案 1 :(得分:0)
设置image
属性时是否收到弃用警告?
阅读NSStatusItem
documentation特别注意button
属性:其描述,类型以及该类型继承的内容......
如果在此项研究之后您的新设计出现问题,请提出新问题,显示新代码,毫无疑问,有人会帮助您。
答案 2 :(得分:-1)
您使用
<div class="discord-container">
<center>
<img src="https://i.imgur.com/7K3OLPH.png" class="discord-image" width="75" />
<div class="discord-poupup" id="poupup-element">
<button onClick="discord.logout()" class="logout-button" >LOGOUT</button>
</div>
</center>
</div>
但是,这已被弃用
答案 3 :(得分:-1)
OC:
#define DEFAULT_W 80
#define DEFAULT_H 22
NSTextField* txt = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, DEFAULT_W, DEFAULT_H)];
txt.stringValue = @"Hellow world!";
mStatusBackgroundView = [[NSView alloc]initWithFrame:NSMakeRect(0, 0, DEFAULT_W, DEFAULT_H)];
[mStatusBackgroundView addSubview:txt];
mStatusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:DEFAULT_W];
mStatusItem.view = mStatusBackgroundView;
夫特:
let DEFAULT_W = 80
let DEFAULT_H = 22
let txt = NSTextField(frame: NSMakeRect(0, 0, CGFloat(DEFAULT_W), CGFloat(DEFAULT_H)))
txt.stringValue = "Hellow world!"
mStatusBackgroundView = NSView(frame: NSMakeRect(0, 0, CGFloat(DEFAULT_W), CGFloat(DEFAULT_H)))
mStatusBackgroundView.addSubview(txt)
mStatusItem = NSStatusBar.system().statusItem(withLength: CGFloat(DEFAULT_W))
mStatusItem.view = mStatusBackgroundView;