iOS 10.3.1 update breaks some NSAttributedString properties? - nsmutableattributedstring

I'm going to ask and then answer my own question in the hope that this will help someone.
Our app used NSMutableAttributedString to define a strikethrough attribute for certain parts of our string.
NSRange range = [fullString rangeOfString:product.originalDeal];
[dealString addAttribute:NSFontAttributeName value:[UIFont fontWithSize:12] range:range];
[dealString addAttribute:NSStrikethroughStyleAttributeName value:#1 range:range];
[dealString addAttribute:NSStrikethroughColorAttributeName value:[UIColor grayColor] range:range];
[dealString addAttribute:NSForegroundColorAttributeName value:[UIColor grayColor] range:range];
In iOS 10.3 we noticed that the strikethrough feature no longer occurred consistently. Sometimes it was present, other times it was absent.
Question: How to get the strikethrough working again?

Here's how we fixed it:
[dealString addAttribute:NSBaselineOffsetAttributeName value:#(1) range:range];
at the bottom of our attributes listing. This overcame the issue in both iOS 10.3 and 10.2.
Note that if the string contains the element \n and the offset attribute range includes that element, it would also break (no strikethrough). We applied the offset to just the portion of the string to generate the strikethrough.
The other attributes - gray and font - were not affected.

Related

CSS styling with really long classes

this is my first question here, hope I am doing this right :)
I am trying to change the colours of the calendar on this page:
https://realsailing3.vanbruben.de/dehler-41-shelter.
But the classes are as long as
.monthly-fluid .ext_month_day_nox, .monthly-fluid .ext_month_day_nox_r, .ext_month_day_nox.morning_occ_nox
or
ext_month_day_nox no_start nocuscol
or
.monthly-fluid .cur_month_day_nox.arrival_day
I have tried to separate them with a dot but i get the message "dont use adjoining classes"
Any idea of how I can change these colours?
Thank you very much!!
code picture
try to add !important with that property.
.monthly-fluid td.reserved_nox {
background-color: #f0c2c2 !important;
}
It shouldn't matter how long the classes are. If you've used an email client such as Outlook before, classes act the same way as tags do in Outlook. You can "categorize" each element as cur_month_day_nox or no_start or nocuscol, or any combination of them. Then when the element is styled using CSS, the file will describe how elements will appear based on their categorizations. Each description is called a "rule."
We want to look for a rule which modifies the background-color, since our objective is to change it the color of the day. While the element is selected in the Inspector, If you look on the right pane called Styles and scroll enough, you'll find the following CSS rule:
.monthly-fluid .cur_month_day_nox {
background-color: #c2dfd0;
}
This style "selects" any elements which have the class .cur_month_day_nox, which is all the green days with the exception of today (at the time of writing, that's February 1st). So, you can double click the color value and change it. You should see all the green days change instantly.
Edit: For a weird reason, the class names are different on your end, but regardless the approach is the same.

Failed to set an indexed property on 'CSSStyleDeclaration': Index property setter is not supported

I am getting above error in my react project when chrome version is updated to 74 (latest version).
The root cause of this issue is described here. Essentially this happens when you pass style property of some elemnt as string or array. Like style="string" or style={[array]}. This may seem not relevant (I don't think that someone intentionally try to send string or Array to style property), but in my case this was root cause.
To find error I recommend to carefully investigate your code with debugger in Chrome or other browser.
Below is example of my error
I erroniously set styles.radioButton (which is used as value for style property for some element) using spread operator ...spacing.xxSmall, but spacing.xxSmall is just a string and spreaded to array with chars as array members. Previously properties with indexes (0, 1, 2, ...) of style has been ignored, but now site is crushed.
I work with Angular libraries and some of them does not support inline styles now (for me it was ngx-avatar and it not working on Firefox and chrome: 74)
before:
<ngx-avatar style="border-radius="50%"></ngx-avatar>
after:
<ngx-avatar [style.border-radius]="'50%'"></ngx-avatar>
I think you can try the same for React.
In my RN Expo Web application I was getting this error while doing something like
style={{ padding: 5, ...props.style }}
I Realized that passing prop named "style" and then using it as inline style was causing this error. What resolved it for me was using a different name for the prop and doing something like ...
style={{ padding: 5, ...props.listSectionStyle }}
Merely changing prop name from 'style' to anything else like 'listSectionStyle' (or any of your choice) should resolve if it is due to above stated reason.
Ref: link shared by Fyodor in his reply helped understand the real issue.
I was getting this error with prime ng's <p-skeleton>. What I was doing is passing a style directly to the skeleton like below:
<p-skeleton width="97.5%" height="20rem" style="margin-bottom: 2rem;"></p-skeleton>
So instead of using style directly I used the class property to give the margin bottom (my class was already defined). This removed the error for me. And updated line is as follows:
<p-skeleton width="97.5%" height="20rem" borderRadius="16px" class="mb-40"></p-skeleton>
For Expo/RN
You're probably giving an array of malformed stylesheets this way:
<compo style={[foo, biz, bar]} />
What you need to do is flatten your stylesheets:
import * as Native from 'react-native';
<compo style={Native.StyleSheet.flatten([foo, biz, bar])} />

how to underline a letter of button caption in vaadin?

I'm using keyboard shortcuts in my Vaadin application. So i want to highlight one letter in button caption. The underline might be for first or second or third letter of the caption.
I am able to underline the first letter by using the "first-letter" property of CSS. How to underline second or third letter?
NativeButton btn = new NativeButton("Edit");
btn.addStyleName("myunderline");
.mytheme .myunderline.v-nativebutton::first-letter {
text-decoration: underline;
}
Is there any solution?
Thankyou!!!
So I want to highlight one letter in button caption...
You have not specified the vaadin version you are using. But latest vaadin 7 (> 7.4) versions support HTML in Button caption.
NativeButton nb = new NativeButton("<u>E</u>dit");
nb.setCaptionAsHtml(true);
Is posible to indicate it using & symbol during shortcut listener creation.
According Vaadin docs:
https://vaadin.com/docs/-/part/framework/advanced/advanced-shortcuts.html
// A field with Alt+A bound to it, using shorthand notation
TextField address = new TextField("Address (Alt+A)");
address.addShortcutListener(
new AbstractField.FocusShortcut(address, "&Address"));
Hope it helps.
Looks like there's no simple CSS solution, based on This Answer where someone is trying to do the same, and This Answer from the Vaadin forums.
Basically, your simplest option is to wrap the letter you want to underline in its own element which applies the underline:
<button ...>Te<span class=underline>x</span>t</button>
... Or something along those lines. The first link above has an answer which references a number of other JS libraries (lettering.js, nth-everything-css) which might be able to help you out.

get computed font size of GWT Label

I'd like to be able to access the font size of a GWT Label. I've tried:
String fontSize = label.getElement().getStyle().getFontSize()
but this seems to only be for font sizes that have been programatically set (and not font sizes that are decided by CSS rules). Any ideas?
Thanks,
~Owen
If it is the computed size you are looking for, GWT does not provide it out of the box, but you should be able to use a simple JSNI to retrieve it. Something like:
public static native String getComputedStyleProperty(Element element, String property) /*-{
if ($doc.defaultView && $doc.defaultView.getComputedStyle) {
return $doc.defaultView.getComputedStyle(element, null).getPropertyValue(property);
}
return "";
}-*/;
Untested but should get you started. Do note that, the property should be camelCase and, for IE < 9, you should also check for currentStyle. Also a fallback based on element's style property should be returned, instead the empty string.
See also Get computed font size for DOM element in JS.
No, getFontSize() returns CSS property only.
Give a try like below:
String fontsize= DOM.getStyleAttribute(label.getElement(), "font-size");

How to add background-image to a div?

I am working with the Mojo SDK and I'am trying to add a background image to a div but havn't been able to find a way to do it.
Obviously I have tried doing it the normal CSS-way but it doesn't seem to work with Mojo.
Here is the latest thing I tried:
var t=document.getElementById("kblayoutdiv");
t.parentNode.removeChild(t);
var t=document.getElementsByTagName("BODY")[0];
var div=document.createElement("div");
div.style.position="fixed";
div.id="kblayoutdiv";
div.style.display="block";
div.style.top="80%";
div.style.left="92%";
div.style.width="16px";
div.style.height = "11px";
div.style.background = url('/usr/palm/frameworks/mojo/keyb_en-us.png');
div.style.zIndex = "255";
t.appendChild(div);
window.kblayout="en";
I have tried several solutions to get the background image to show.
The rest is working fine. It is just the background iamge that won't show no matter what.
So if anyone can show me the piece of code to add the background image I'd be real happy :)
div.style.background = url('/usr/palm/frameworks/mojo/keyb_en-us.png');
You have to quote strings in JavaScript
div.style.background = "url('/usr/palm/frameworks/mojo/keyb_en-us.png')";
Obviously, the URI has to be correct as well.
That said, as a rule of thumb, it is almost always better to predefine all your styles in an external stylesheet and generate elements that match the selectors (e.g. by setting .className).

Resources