Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I've been trying to achieve this:
Basically: A very simple line of text including 2 links. These two link being in semibold when the rest of the text is in regular.
Was trying to get everything done into the same string using the Storyboard.
Surprisingly, it seems to be quite hard to achieve. I can't get myself to understand why something that simple should be so hard. Was expecting to achieve this in the Storyboard view...
Please view the images by clicking this link
Thank you all for your help!
Quentin
I can't help you with storyboard, but you can do it this way programmatically:
first make your label
yourLabel: UILabel =
{
let label = UILabel()
return label
}()
Now, to have some text be bold and the rest not, you need to declare a NSMutableAttributedString and then append it on another string, like this:
yourLabel: UILabel =
{
let label = UILabel()
let attributedText = NSMutableAttributedString(string: "Your Text Here", attributes: [NSFontAttributeName: UIFont.systemFont(ofSize: 14)])
attributedText.append(NSAttributedString(string: "Your Bold Blue Text Here", attributes: [NSForegroundColorAttributeName: UIColor.blue, NSFontAttributeName: UIFont.boldSystemFont(ofSize: 14)]))
label.attributedText = attributedText
return label
}()
You can now also set one of the strings to be a link/button and the other not.
Hope it helps.
Related
This question already has an answer here:
Convert Android.Graphics.Bitmap to Image
(1 answer)
Closed 4 years ago.
I’m relatively new in android programming and have a problem: I want to convert a Bitmap into an Image.
I couldn’t find a way to do this. Probably I’m searching wrong.
Thanks.
Try This way
Drawable drawable = RoundedBitmapDrawableFactory.create(context.getResources(), bitmap);
//set imageview XML - call your image view
imageView.setImageDrawable(drawable);
References : Android Developers /Bitmaps
Drawable imageDrawable = new BitmapDrawable(getResources(), bitmapImg);
So I have googled it and i didn't find any solution there so I am posting my question in here.
So when you write in etherpad, it creates markup which looks like this:
<div id="magicdomid17" class="ace-line">
<span class="author-a-w3z75zz84z95z83zpz77zz89zz66zz79zxz90zz66zcz76z">
Author1.
</span>
<span class="author-a-1z74zz83zuz82z2z67zz815zsz89zz70zz65z8z69zz87z9">
Author2.
</span>
</div>
Now It will output this:
Author1.Author2.
Having different background colors for Author1. and Author2. texts depending upon what writers chose when they started using etherpad.
My question is how etherpad process the data to put background color on specific text.
I know it has something to do with classes given to span as:
author-a-w3z75zz84z95z83zpz77zz89zz66zz79zxz90zz66zcz76z for first author
and
author-a-1z74zz83zuz82z2z67zz81zsz89zz750zz65z8z659zz87z9for second author.
Can anyone explain how the background-color is being put for these texts depending upon these classes name? and which file is responsible for that?
Thanks in advance
So as most of the etherpad questions, no one answered this question either. I got the solution if anyone got same problem for deciding text color depending upon class name.
All you need is define a object variable in your front end js file where you are using the etherpad. In this var we will take author class name as key and its respective color as value.
var window.authClassColorObj = {};
Now go into ace2_inner.js file and find function setAuthorStyle() , add these lines in that function after var authorSelector = getAuthorColorClassSelector(getAuthorClassName(author)); line:
parent.parent.parent.window.authorClassColorObj[getAuthorClassName(author)] = info.bgcolor;
Now i am accessing my front end object var by three layer in, so i am using parent.parent.parent. , it can be different for you depending upon you file structure.
Idea is that this is the place where you can populate your object with proper values.
and then you can access your object from front end, for example for my case, it will out put this:
console.log(window.authClassColorObj);
Output:
object{
author-a-w3z75zz84z95z83zpz77zz89zz66zz79zxz90zz66zcz76z:"#f50966"
author-a-1z74zz83zuz82z2z67zz815zsz89zz70zz65z8z69zz87z9:"#20a251"
}
This info can be used further for any changes you want to make in pad html code.
I've done some looking around in here and on the internet and it doesnt seem super obvious, but my question is can python using tkinter be used to automatically convert a text string into a link that loads a pdf from a certain direction
e.g. data '12345 Issue A' pops up in a text widget and is automatically converted to a link that when clicked opens up a pdf document.
Can this or can it not be done ?
In this case I'm wanting to be able to click 1931-125, 699-126 and 1851-127 and have each open up a pdf file of the same name. This is being used in a manufacturing environment and allows an assembler to click the fields and have all the documents they need to build a certain item
First off to apply formatting to parts of a Text widget you will need to understand about tags, in most cases you can probably just use the phrase of the link (ABC123) just remember that:
The name of a tag can be any string that does not contain white space or periods.
once you have a tag for the link there are two parts:
Formatting the tag to look and react like a link.
Applying the tag to the phrases in text.
The first one is really simple if you just want it to be blue and underlined and respond to being clicked:
def format_link(text_widget,tag,command):
text_widget.tag_config(tag,foreground="blue",underline=1)
text_widget.tag_bind(tag,"<Button-1>",command)#remember that the command will need to take an event argument
Although this could get more complicated if you want the cursor to change when hovering over or colour to change after clicking etc.
The second part is to apply this tag to the text automatically which I'm assuming means parse the text after it is inserted into the widget. This is also very simple by putting this answer in a loop so that it checks for every occurrence of the phrase:
def apply_tag(text_widget,phrase,tag,regexp=False):
countVar = tk.IntVar(text_widge)
idx = "1.0"
while idx:
idx = text_widget.search(phrase,idx, stopindex = "end",
count = countVar, regexp = regexp)
if idx:
end_idx = "%s + %sc" %(idx, countVar.get())
text_widget.tag_add(tag, idx, end_idx)
idx = end_idx
Then all that is left is defining the way to open the file in another program and then calling the two above functions, using os.system("open"...) to open files it could be as simple as:
def make_link(text,phrase,file_to_open):
def callback(event=None):
os.system("open %r"%file_to_open)#there are better ways of handling this
apply_tag(text,phrase,phrase)#uses phrase as tag
format_link(text,phrase,callback)
Although you might want to look at answers here or it's duplicate for alternatives for opening files.
after inserting the text into the widget, assuming you have some sort of list of phrases to turn into links, you can just loop over the phrases and call make_link for each one:
phrases = {"1931-125", "699-126", "1851-127"}
for s in phrases:
make_link(TEXT_W, s, s+".pdf") #make a link to same name with .pdf added to end.
When I test my app on IOS7 simulator.
Sometimes I found it is weird when I using sizeToFit of a UITextView.
The frame after sizeToFit seems right but the text can only show partly just like the photo below. (The gray area represents the UITextView new frame after sizeToFit, the whole sentence should be "which sparked a tense relationship between the two.")
The UITextView text is set via attributedText.
It seems the problem occurs with some sentences only and is OK for most sentences.
I met this problem several times and can not solve it yet.
Any help will be appreciated. Thanks.
Update:
Finally I solve the problem in an ugly way. I reset the text of the textView.
NSString *text = textView.text;
textView.text = #"";
textView.text = text;
Now it can show the whole content after sizeToFit.
I think it seems like a IOS 7's bug.
I had the same problem, it took me a while to figure it out, you simply need to resize the text container
[textview sizeToFit];
[textview.textContainer setSize:textview.frame.size];
Noticed in IOS7 sizeToFit wasn't working also - perhaps the solution may help you too, needs the additional layoutIfNeeded
[UITEXTVIEW sizeToFit];
[UITEXTVIEW layoutIfNeeded];
[UITEXTVIEW setTextContainerInset:UIEdgeInsetsMake(0, 0, 0, 0)];
Have you got "clip subviews" checked in interface builder?
Try to uncheck it or setting this property to "NO".
Try this it worked for me.
[textView setTextContainerInset:UIEdgeInsetsMake(0, 0, 0, 0)];
I am working on a project with a few dynamic text boxes. I want to have one of the boxes show the variable "frameWeightText" and them "lbs" Here is some of the code:
var frameWeightText:String;
var frameWeight:Number;
frameWeight = 16;
frameWeightText = frameWeight.toString();
base_info.frameWeightBox.text = frameWeightText + "lbs";
The text box only shows "lbs" but not 16 before that.
Your code all looks fine to me, but have you made sure to embed the font you're using? If you haven't, but the text field on the stage has "lbs" already typed in, that would explain only those characters showing up.
David Mear is right. surfaspen you should embed fonts to library and actionscript