Howto change the fontsize of an attributes array (swift, ios) -


i have function follow, creates attributes array. reuse attributes lot of textdrawing.

func getfontattributes(ftextsize:cgfloat, color:uicolor, alignment:string) -> [nsobject : anyobject]{       let fieldfont = uifont(name: "helvetica neue", size: ftextsize)     var parastyle = nsmutableparagraphstyle()      parastyle.linespacing = 6.0     if (alignment=="left"){     parastyle.alignment = nstextalignment.left;     }else if(alignment=="right"){         parastyle.alignment = nstextalignment.right;     }else{         parastyle.alignment = nstextalignment.center;     }      var skew = 0.1      let attributes = [         nsforegroundcolorattributename: color,         nsparagraphstyleattributename: parastyle,         nsobliquenessattributename: skew,         nsfontattributename: fieldfont!     ]     return attributes;  } 

how can change 1 single attribute of attributes (for example fontsize) afterwards ? don't call function getfontattributes again.

let attributes=getfontattributes(14, uicolor.darkgraycolor(),"left"); attributes.setfontsize(16); // <----- howto ? 

i pretty sure must possible stuck syntax , typeconversion.

this dictionary , not array. every time call fucntion new instance of dictionary.

so can call once:

var attrdict = getfontattributes(14, uicolor.darkgraycolor(),"left") 

and do:

attrdict[nsfontattributename] = uifont(name: "helvetica neue", size: newsize) 

Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -