嗨,我正在尝试使用UILabel图层绘制一个圆形,但是,我的标签仅显示数字,而不显示我为标签创建的背景颜色或边框。为什么是这样 ?这是我的代码:
let countLabel = UILabel()
countLabel.text = "5"
let size:CGFloat = 55.0
countLabel.textColor = UIColor.white
countLabel.textAlignment = .center
countLabel.font = UIFont.systemFont(ofSize: 14.0)
countLabel.bounds = CGRect(x : 0.0,y : 0.0,width : size, height : size)
countLabel.layer.cornerRadius = size / 2
countLabel.layer.borderWidth = 3.0
//countLabel.layer.masksToBounds = true
countLabel.layer.backgroundColor = UIColor.orange.cgColor
countLabel.layer.borderColor = UIColor.orange.cgColor
countLabel.center = CGPoint(x:200.0,y: 200.0)
countLabel.translatesAutoresizingMaskIntoConstraints = false
self.topContainer.addSubview(countLabel)
countLabel.topAnchor.constraint(equalTo: profileImage.topAnchor).isActive = true
countLabel.trailingAnchor.constraint(equalTo: profileImage.trailingAnchor, constant: 10).isActive = true
Run Code Online (Sandbox Code Playgroud)
我想得到这样的东西。
但是上面没有输出橙色。为什么呢?
我一直在运行一个脚本,我使用该ord()函数,无论在python 2.7中的原因是什么,它都接受unicode字符串字符,并且输出一个整数.
在python 3.4中,情况并非如此.这是正在生成的错误输出:
Traceback (most recent call last):
File "udpTransfer.py", line 38, in <module>
buf.append(ord(c))
TypeError: ord() expected string of length 1, but int found
Run Code Online (Sandbox Code Playgroud)
当我查看两个文档时,ord函数被解释为做同样的事情.
这是我用于两个python版本的代码:
import socket,sys, ast , os, struct
from time import ctime
import time
import csv
# creating the udo socket necessary to receive data
sock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
ip = '192.168.10.101' #i.p. of our computer
port = 20000 # socket port opened to connect from the matlab udp send data stream
server_address …Run Code Online (Sandbox Code Playgroud) 嗨,我想打印一个字符串,同时在最后添加点,而不是每次重复打印字符串之前重新打印字符串.我希望它能够打印,但只将点添加到已打印的字符串中.
reboot = '### rebooting the mmp';
display(reboot)
for i = 1 : 15
reboot = strcat(reboot,'.')
pause(1);
end
Run Code Online (Sandbox Code Playgroud)
我该怎么办?